This is an archive of the discontinued LLVM Phabricator instance.

Support the setjmp(3) family of functions in TSan/NetBSD
ClosedPublic

Authored by krytarowski on Nov 22 2017, 2:05 AM.

Details

Summary

This change adds support for the setjmp(3)/longjmp(3)
family of functions on NetBSD.

There are three types of them on NetBSD:

  • setjmp(3) / longjmp(3)
  • sigsetjmp(3) / sigsetjmp(3)
  • _setjmp(3) / _longjmp(3)

Due to historical and compat reasons the symbol
names are mangled:

  • setjmp -> __setjmp14
  • longjmp -> __longjmp14
  • sigsetjmp -> __sigsetjmp14
  • siglongjmp -> __siglongjmp14
  • _setjmp -> _setjmp
  • _longjmp -> _longjmp

This leads to symbol renaming in the existing codebase.

There is no such symbol as sigsetjmp/longsetjmp
on NetBSD

Add a comment that GNU-style executable stack
note is not needed on NetBSD. The stack is not
executable without it.

Sponsored by <The NetBSD Foundation>

Diff Detail

Repository
rL LLVM

Event Timeline

krytarowski created this revision.Nov 22 2017, 2:05 AM
dvyukov added inline comments.Nov 28 2017, 2:44 AM
lib/tsan/rtl/tsan_interceptors.cc
556

I am somewhat disappointed by amount of copy-paste between netbsd and linux. I think we should do the same thing you did with sigaction_symname, because it's effectively the same problem.

I.e. (under !SANITIZER_MAC):

#if SANITIZER_NETBSD
# define setjmp_symname __setjmp14
...
#else
# define setjmp_symname setjmp
...
#endif

And then use setjmp_symname in the rest of the code.
I see that netbsd has 1 less setjmp flavor and 1 more longjmp flavor. So we could put 1 setjmp under #if SANITIZER_LINUX and 1 longjmp under #if SANITIZER_NETBSD.

Will this work?

I will give it a try.

Can I extract the LongJmp change and commit to the main sources now as it?

dvyukov edited edge metadata.Nov 28 2017, 3:11 AM

I will give it a try.

Can I extract the LongJmp change and commit to the main sources now as it?

LongJmp part looks good to me.

krytarowski edited the summary of this revision. (Show Details)

Try to share more code between NetBSD and Linux.

Drop LongJmp part from the patch as committed separately upstream.
http://llvm.org/viewvc/llvm-project?rev=319163&view=rev

krytarowski marked an inline comment as done.Nov 28 2017, 8:00 AM
dvyukov accepted this revision.Nov 28 2017, 9:26 AM
This revision is now accepted and ready to land.Nov 28 2017, 9:26 AM
krytarowski closed this revision.Nov 28 2017, 9:35 AM
vlad.tsyrklevich added inline comments.
lib/tsan/rtl/tsan_interceptors.cc
600

This is misspelled here and twice below as well meaning it's never actually compiled. Is it actually necessary?

krytarowski added a comment.EditedJan 25 2018, 1:49 AM
This comment has been deleted.
lib/tsan/rtl/tsan_interceptors.cc
600

Ah, good catch!

It's actually meaning that it's compiled always, also on NetBSD. I will try to disable it and check if there are regressions, if not I will commit a fix.

krytarowski added inline comments.Jan 25 2018, 3:09 AM
lib/tsan/rtl/tsan_interceptors.cc
600