Hi,

I had some time to look at https://issues.apache.org/jira/browse/ARROW-10039,
wrt to the alignment requirements that rust implementation currently
imposes.

The gist is that it is not that easy, and I would like to request some
guidance.

Some facts:
1. Our current implementation does not accept a pointer if that pointer is
not memory aligned (we panic)
2. Our rust implementation's alignment is a static/const that depends on
the architecture and therefore constant throughout the program
3. Rust alloc/dealloc both require an argument denoting memory alignment.
4. calling dealloc with the wrong alignment is undefined behavior

3-4 imply that removing our safeguard against unaligned memory (wrt to the
constant alignment) leads to undefined behavior: we take ownership of a
pointer with an alignment X != our alignment and when we try to free it, we
enter undefined world.

Some options:

1. do not support interoperability (status quo)
2. do not support pointer-based memory sharing (e.g. re-align the pointer
with a memcopy)
3. do not support owned pointer-based memory sharing (i.e. never call
dealloc on that data)
4. infer the alignment of the pointer, and keep track of the pointer's
alignment as part of its metadata (e.g. on `BufferData`)

Any ideas or preferences?

Best,
Jorge

Reply via email to