Closed Bug 1182382 Opened 5 years ago Closed 3 years ago

Building NSS with ASan on Mac fails: "Undefined symbols: ___asan_*"

Categories

(NSS :: Build, defect)

defect
Not set

Tracking

(firefox42 affected)

RESOLVED WORKSFORME
Tracking Status
firefox42 --- affected

People

(Reporter: jruderman, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Building Firefox with ASan on Mac (setup described in bug 1182378)

> /Users/jruderman/llvm//build/Release/bin/clang -bundle  -exported_symbols_list /Users/jruderman/builds/mozilla-central-asan-opt/security/nss/lib/ckfw/builtins/nssckbi.def -o /Users/jruderman/builds/mozilla-central-asan-opt/security/nss/lib/ckfw/builtins/libnssckbi.dylib /Users/jruderman/builds/mozilla-central-asan-opt/security/nss/lib/ckfw/builtins/anchor.o /Users/jruderman/builds/mozilla-central-asan-opt/security/nss/lib/ckfw/builtins/constants.o /Users/jruderman/builds/mozilla-central-asan-opt/security/nss/lib/ckfw/builtins/bfind.o /Users/jruderman/builds/mozilla-central-asan-opt/security/nss/lib/ckfw/builtins/binst.o /Users/jruderman/builds/mozilla-central-asan-opt/security/nss/lib/ckfw/builtins/bobject.o /Users/jruderman/builds/mozilla-central-asan-opt/security/nss/lib/ckfw/builtins/bsession.o /Users/jruderman/builds/mozilla-central-asan-opt/security/nss/lib/ckfw/builtins/bslot.o /Users/jruderman/builds/mozilla-central-asan-opt/security/nss/lib/ckfw/builtins/btoken.o /Users/jruderman/builds/mozilla-central-asan-opt/security/nss/lib/ckfw/builtins/certdata.o /Users/jruderman/builds/mozilla-central-asan-opt/security/nss/lib/ckfw/builtins/ckbiver.o   /Users/jruderman/builds/mozilla-central-asan-opt/dist/lib/libnssckfw.a /Users/jruderman/builds/mozilla-central-asan-opt/dist/lib/libnssb.a  -L/Users/jruderman/builds/mozilla-central-asan-opt/dist/lib -lplc4 -lplds4 -lnspr4

Undefined symbols for architecture x86_64:
  "___asan_handle_no_return", referenced from:
      _nssCKFWMechanism_Destroy in libnssckfw.a(mechanism.o)
  "___asan_init_v5", referenced from:
       ...

I think the problem is that one of the NSS build commands doesn't use any of {CFLAGS,CXXFLAGS,LDFLAGS}, so it doesn't pick up the "-fsanitize-address" needed in all linker invocations.

As described in bug 1182378, I'm working around this in my mozconfig, by including "-fsanitize=address" in {CC,CXX} as well as {CFLAGS,CXXFLAGS,LDFLAGS}. I'm guessing this isn't the correct solution, but if it is we can add it to https://developer.mozilla.org/en-US/docs/Mozilla/Testing/Firefox_and_Address_Sanitizer.
> by including "-fsanitize=address" in {CC,CXX} as well as {CFLAGS,CXXFLAGS,LDFLAGS}.

That's what we do in our asan builds.
(see build/unix/mozconfig.asan)
Eh? In https://dxr.mozilla.org/mozilla-central/source/build/unix/mozconfig.asan, I only see "-fsanitize=address" in {CFLAGS,CXXFLAGS,LDFLAGS}.
Attached file build log
I think the problem is that "-fsanitize=address" isn't making its way into MKSHLIB-based commands:

https://dxr.mozilla.org/mozilla-central/source/security/nss/coreconf/Darwin.mk#109
My changes in bug 1233568 should fix this for the case of building NSS itself with USE_ASAN=1 (the option added in that patch), although I haven't tried it with top-of-tree LLVM on Mac yet.
WFM on macOS with GYP. We're planning to remove USE_ASAN from the Makefile build system soon-ish.
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.