-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
aligned_malloc() calls unaligned std::malloc() #1651
Comments
stefanbuettner
added a commit
to stefanbuettner/pcl
that referenced
this issue
Jul 29, 2016
…turn aligned memory See PointCloudLibrary#1651. On 32-bit Windows, for example, aligned_malloc did not use aligned memory allocation due to wrong preprocessor definitions. Sets ALIGNED_MALLOC to 1 in case someone really checked that value.
Hi Chungzuwalla, looks like a bug indeed. Thanks for the notification. I'll file a fix. Cheers, |
SergioRAgostinho
added a commit
that referenced
this issue
Aug 18, 2016
Fixes issue #1651: aligned_malloc does not always return aligned memory
SergioRAgostinho
pushed a commit
to SergioRAgostinho/pcl
that referenced
this issue
Aug 19, 2016
…turn aligned memory See PointCloudLibrary#1651. On 32-bit Windows, for example, aligned_malloc did not use aligned memory allocation due to wrong preprocessor definitions. Sets ALIGNED_MALLOC to 1 in case someone really checked that value.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Due to a bug in pcl_macros.h, aligned_malloc() will always call (the possibly unaligned) std::malloc(), regardless of the platform or configuration flags. On 32-bit Windows at least, this will cause a crash.
offending code
MALLOC_ALIGNED is #defined as 0 or 1 depending on whether std::malloc() is believed to be aligned. However, the implementation of aligned_malloc() only tests whether MALLOC_ALIGNED is #defined, which it always is. Therefore, std::malloc() is always used, even when MALLOC_ALIGNED is 0.
Your Environment
Expected Behavior
aligned_malloc() returns memory with 16-byte alignment on Win32.
Current Behavior
aligned_malloc() returns memory with 8-byte alignment on Win32, causing a crash.
Possible Solution
define MALLOC_ALIGNED only when std::malloc() is believed to be aligned.
i.e.:
#if defined(__APPLE__) || defined(_WIN64) || GLIBC_MALLOC_ALIGNED || FREEBSD_MALLOC_ALIGNED
#define MALLOC_ALIGNED
#endif
The text was updated successfully, but these errors were encountered: