New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transform.pd alignment issues #200
Comments
'ovec' is a contiguous collection of many different pointers. Each of these may not be aligned, depending on the sizes that came before. We round each sub-alignment to 16 bytes, so that the resulting pointers are always on 16 byte boundaries. On certain configurations (e.g. Ubuntu's armhf builders), unaligned access raises a SIGBUS which terminates the program, so this is a real problem. Fixes PDLPorters#200.
See the referenced commit - I'm not at all sure it's right (new to alignment matters), so not proposing a PR. Feel free to cherry-pick if you want, or just use it for inspiration. |
Thanks for the report. Could you attach the output of perl -V to this ticket. Presumably, there should be something in the build options about making pointer 16byte aligned....I hope. |
Ahh, I didn't know about perl -V
So that's actually 8-byte aligned if |
For reference, here is a link with discussion of the issue(s): |
Looking at the code in transform.pd, it seems the general fix needs to be to add proper consideration of memory alignment constraints during data allocation. From your perl -V output, you have ptrsize=4, doublesize=8, ivsize=sizeof(PDL_Index)=8, and alignbytes=8. A quick fix for this plaform would be to use some type of memalign to allocate the memory. |
It looks like the problem with the existing code is the generation of the pointers to the memory regions. It gets off for the char data where the calculation does not include the needed alignment. It looks like the calculations do not include little-endian versus big-endian hardware either. |
@iainlane I recently updated all of that bit of Could you possibly try the latest |
In fact, I will be bold and close this on the assumption that it's fixed, but please reopen and/or comment if that's not the case! |
As far as I can tell it's because this code doesn't ensure that the pointers are aligned. In Ubuntu we have kernels which raise SIGBUS on unaligned access, exposing this failure.
I've got a crude fix to align everything to 16 in this function; just testing it.
The text was updated successfully, but these errors were encountered: