This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Align objects with alignas
ClosedPublic

Authored by vitalybuka on May 4 2021, 4:58 PM.

Details

Summary

Operator new must align allocations for types with large alignment.

Before c++17 behavior was implementation defined and both clang and gc++
before 11 ignored alignment. Miss-aligned objects mysteriously crashed
tests on Ubuntu 14.

Alternatives are compile with -std=c++17 or -faligned-new, but they were
discarded as less portable.

Diff Detail

Event Timeline

vitalybuka created this revision.May 4 2021, 4:58 PM
vitalybuka requested review of this revision.May 4 2021, 4:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2021, 4:59 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
pcc added a subscriber: pcc.May 4 2021, 5:09 PM

I'm not sure that we can do this until all of our minimum compiler versions support C++17. E.g. minimum gcc version is 5.1.0 which was released in 2015, so it presumably doesn't have C++17 support.

hctim added a comment.May 4 2021, 6:04 PM

I'm not sure that we can do this until all of our minimum compiler versions support C++17. E.g. minimum gcc version is 5.1.0 which was released in 2015, so it presumably doesn't have C++17 support.

Looks like gcc 5.1 has support for -std=c++17, but unfortunately no support for -faligned-new (which I thought would be preferable to bumping to cxx17).

Shouldn't we just mark the individual test rather than bumping the whole allocator?

I'm not sure that we can do this until all of our minimum compiler versions support C++17. E.g. minimum gcc version is 5.1.0 which was released in 2015, so it presumably doesn't have C++17 support.

Looks like gcc 5.1 has support for -std=c++17, but unfortunately no support for -faligned-new (which I thought would be preferable to bumping to cxx17).

I would prefer -std=c++17 as more portable.

Shouldn't we just mark the individual test rather than bumping the whole allocator?

Why? No one complained when you asked for entire compiler-rt.

I'm not sure that we can do this until all of our minimum compiler versions support C++17. E.g. minimum gcc version is 5.1.0 which was released in 2015, so it presumably doesn't have C++17 support.

Probably I should be able to convert tests to allocate aligned stuff on the stack.

vitalybuka updated this revision to Diff 342933.May 4 2021, 8:36 PM

switch to new overload

vitalybuka retitled this revision from [scudo] Compile with -std=c++17 to [scudo] Align objects with alignas.May 4 2021, 8:39 PM
vitalybuka edited the summary of this revision. (Show Details)
hctim accepted this revision.May 5 2021, 10:56 AM

Shouldn't we just mark the individual test rather than bumping the whole allocator?

Why? No one complained when you asked for entire compiler-rt.

I was planning on abandoning that patch after your fix in D101514. It's not clear to me whether there's going to be enough benefit to switch crt to c++17, but these two bugs in the last two weeks are definitely fresh in the mind. Maybe let's bring it up in the next team meeting.

This test fix LGTM.

This revision is now accepted and ready to land.May 5 2021, 10:56 AM

BTW Allocating them on stack is not an option. TestConfig1 on 64bit defines allocator as .5GB object :)

This revision was landed with ongoing or failed builds.May 5 2021, 1:29 PM
This revision was automatically updated to reflect the committed changes.