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

strict_init_order=false mode of init-order checking doesn't work on Darwin #186

Open
ramosian-glider opened this issue Aug 31, 2015 · 5 comments

Comments

@ramosian-glider
Copy link
Member

Originally reported on Google Code with ID 186

The non-strict order mode relies on the fact that all __asan_register_globals() calls
will occur before the dynamic initialization of the globals, so that the tool will
know about every global before trying to initialize anything.
This assumption is broken on Darwin, because the linker does not support static constructor
priorities across translation units, and usually _all_ the static constructors from
a certain module will be executed before moving on to a next module.

This means that the only way to use the init-order checker on Darwin is to run it in
the strict_init_order=true mode, which is prone to false positives (Alexey, please
correct me if I'm wrong)

There are several things we can do about this:

1. Declare strict_init_order=true the default (or the only possible) option on Darwin.
2. Declare the init-order-checker broken on Darwin.
3. Create a section with appending linkage that contains pointers to ASan's per-module
constructors. Once any of those is executed, it calls every other constructors. This
way we'll make sure ASan constructors are executed before others (we still won't have
full support for constructor priorities, but we don't actually need it).

Reported by ramosian.glider on 2013-05-17 12:53:07

@ramosian-glider
Copy link
Member Author

As the folks have pointed out in an offline chat today, the problem applies to addressability
checking in globals as well as init order checking.
For example, it may turn out that a static constructor of one module may access a global
array from another module out of its bounds. If this happens before that global array
is registered (which is possible on Darwin), ASan won't report the error.

Reported by ramosian.glider on 2013-05-20 17:51:35

@ramosian-glider
Copy link
Member Author

I've marked the init-order test as XFAIL on Darwin for now (r182365).

Reported by samsonov@google.com on 2013-05-21 10:12:17

@ramosian-glider
Copy link
Member Author

Reported by ramosian.glider on 2015-07-30 09:05:31

  • Labels added: ProjectAddressSanitizer

@ramosian-glider
Copy link
Member Author

Adding Project:AddressSanitizer as part of GitHub migration.

Reported by ramosian.glider on 2015-07-30 09:06:55

@rgov
Copy link

rgov commented Feb 10, 2016

This is partially addressed by D16737 since it registers all globals across all TUs simultaneously, but it does not guarantee (as far as I can tell) that this happens before any other constructor executes.

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

No branches or pull requests

2 participants