Skip to content
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

Align the result of operator new to alignof(max_align_t) #9

Open
tzik opened this issue Aug 21, 2017 · 1 comment
Open

Align the result of operator new to alignof(max_align_t) #9

tzik opened this issue Aug 21, 2017 · 1 comment

Comments

@tzik
Copy link

tzik commented Aug 21, 2017

The C++ spec requires the result of operator new to be aligned to alignof(max_align_t), which is 16 on x86_64 Linux. However, lean's operator new returns 8 byte aligned memory under tcmalloc, where malloc_usable_size, malloc_size and _msize are unavailable.
As clang assumes 16-byte-aligned memory and uses movaps for zero-filling, 8-byte-aligned memory causes a segmentation fault.

The 8-byte alignment is from lean::save_alloc_size in src/util/memory.cpp, that stores the size of allocation into a 8 byte leading region of the allocated memory chunk. So, to fix the alignment issue, the leading region should be alignof(max_align_t) instead of a single size_t.

@ghost
Copy link

ghost commented Oct 1, 2018

I think I'm having the same issue. I don't immediately know how your suggestion should be coded, though. Temporarily disabling TCMALLOC at least gave me a working binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant