3 ms·
While I do agree with you, and think it's probably worth seeing if detecting the override and falling back to unaligned allocation works, the problem is not tha
by olliej 4y ago
While I do agree with you, and think it's probably worth seeing if detecting the override and falling back to unaligned allocation works, the problem is not that the code in TF is compiling assuming/requiring over aligned data.
The problem is that there is system code that they are calling that is making using of over aligned allocation, so therefore could be generating code dependent on said alignment. The failure mode can very easily be
someSystemLibrary.so`someFunction:
alignedThing = ::operator new(size, alignment)
...
i_dunno_dma_memcpy_or_something(a, somewhere else)
...
::operator delete(a)
With no interaction with TF code at all. Except TF has replaced operator delete so that fails due to the allocator mismatch. If you make ::opeator new(size_t, align_val_t) redirect to ::operator new(size_t) if it detects an override then the aligned operation can fail. The above example is moderately difficult to induce so it's more likely that there's an explicit split with the system is doing one half of new/delete and TF is doing the other, but the important thing is that it implies the system code is built aware of alignment and it depends on the alignment even if TF does not.