Page MenuHomePhabricator

Teach clang/NetBSD about additional dependencies for sanitizers
ClosedPublic

Authored by krytarowski on Dec 9 2017, 6:49 PM.

Details

Diff Detail

Repository
rC Clang

Event Timeline

krytarowski created this revision.Dec 9 2017, 6:49 PM

I'm not really a fan of linking libutil into all binaries. Why is this code using forkpty in first place and not posix_openpt/grantpt?

I'm not really a fan of linking libutil into all binaries. Why is this code using forkpty in first place and not posix_openpt/grantpt?

pid_t
forkpty(int *amaster, char *name, struct termios *term, struct winsize *winp);

We need to teach sanitizers how to mark as initialized structs passed to this function.

Sanitizers are for development only, so it's the trade-off of linking with additional libraries.

One problem with interceptors is that any sanitized binary looks (to a configure-like script) as if it implements forkpty. But an attempt to use forkpty without actually linking -lutil will fail at runtime, because interceptors are just wrappers.

-lutil is just the same case as -lrt or -lm here.

The potential problem with with autoconf and similar is the design problem, not NetBSD linking here with -lutil.

Without this -lutil, every sanitizer with interceptors will generate spurious dlerror() errors for the lack of forkpty.

Yes, I support adding -lutil - sorry I was not clear about that.

By dlerror() errors, do you mean the warnings about missing interceptors that appear with verbosity=1 (non-fatal), or something else?

In particular, this issue has been detected with dtls_test.c (MSan test), but it is valid to every program checking dlerror().

I've pluged more missing symbols through D41053, there are still few but I'm now busy with teaching sanitizers about all the NetBSD syscalls and all the NetBSD ioctls.

This patch plugs backtrace(3) and forkpty(3) missing symbols.

eugenis accepted this revision.Dec 18 2017, 11:11 AM
This revision is now accepted and ready to land.Dec 18 2017, 11:11 AM
This revision was automatically updated to reflect the committed changes.