This is an archive of the discontinued LLVM Phabricator instance.

[asan] Make ScopedInErrorReport::current_error_ linker-initialized
Needs ReviewPublic

Authored by kubamracek on Mar 7 2018, 7:23 PM.

Diff Detail

Event Timeline

kubamracek created this revision.Mar 7 2018, 7:23 PM
Herald added a subscriber: Restricted Project. · View Herald TranscriptMar 7 2018, 7:23 PM

Based on other code that uses LINKER_INITIALIZED this seems reasonable. However I have no idea how this is supposed to actually work.

lib/asan/asan_report.cc
205

How does LINKER_INITIALIZED guarantee that the linker will actually initialize the struct? It looks like it's just a member of an enum, so it doesn't actually do anything.

My naive reading of this code is that you're trying to avoid the call to internal_memset(this, 0, sizeof(*this)). It looks like this will mean though that the anonymous union won't be initialized.

kubamracek added inline comments.Mar 8 2018, 11:37 AM
lib/asan/asan_report.cc
205

For global variables, uninitialized = filled with zeroes. Unfortunately, I don't think there is a reasonable way to enforce this. C++14 has constexpr constructors, but I don't think we can use C++14 in compiler-rt (yet).

I have to admit that the way I "tested" the patch was to build compiler-rt, then disassemble the result and look if the static constructor is there or not.

delcypher added inline comments.Mar 16 2018, 1:12 PM
lib/asan/asan_report.cc
205

For global variables, uninitialized = filled with zeroes.

For simple structs yes. For unions inside structs, I'm not sure what happens.

Regardless of that all that, I think an explanation of why this change is being made is the only thing that is missing to accept this patch.

george.karpenkov resigned from this revision.May 30 2018, 4:37 PM
george.karpenkov added a subscriber: george.karpenkov.
filcab removed a reviewer: filcab.Jun 25 2018, 5:34 AM