This is an archive of the discontinued LLVM Phabricator instance.

[libc++abi] Fix test_exception_storage_nodynmem on MacOS
AbandonedPublic

Authored by smeenai on Oct 31 2016, 8:01 AM.

Details

Summary

Mach-O defaults to two-level namespaces, so calloc cannot be
interpositoned. Override it via the default malloc zone instead.

Note: DYLD_FORCE_FLAT_NAMESPACE can be used to enable interpositioning
on Mach-O, but calloc is used during library initialization, so
replacing it with a version which always returns NULL causes segfaults.
This could be worked around, but malloc zones are a cleaner solution.

Event Timeline

smeenai updated this revision to Diff 76409.Oct 31 2016, 8:01 AM
smeenai retitled this revision from to [libc++abi] Fix test_exception_storage_nodynmem on MacOS.
smeenai updated this object.
smeenai added a subscriber: cfe-commits.
ikudrin edited edge metadata.Nov 7 2016, 1:45 AM

This test is extremely fragile. Maybe, it is better to disable it, or even delete it altogether.

This test is extremely fragile. Maybe, it is better to disable it, or even delete it altogether.

I'll take your word for it, as the original author of the test, though I'm curious about where the fragility is coming in from :)

Are you planning to disable/delete, or should I?

The test is too implementation-specific, and trying to override a function like calloc makes it fragile. Unfortunately, I didn't find a better way to test the library's behavior in case of memory exhaustion, but now I believe that this test doesn't add any significant value. I'm going to remove it if no one objects.

EricWF edited edge metadata.Nov 8 2016, 7:56 PM

Go ahead and remove it. Ill try and fix it later next week when I get time.

smeenai abandoned this revision.Nov 9 2016, 1:14 PM

Abandoning this then. In case the new incarnation of the test needs to overwrite any memory allocation methods, this diff has the most reliable way to do it on OS X :)