| Summary: | net/torsocks: sometimes crashes on 12.0-CURRENT | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | Ports & Packages | Reporter: | Jan Beich <jbeich> | ||||||
| Component: | Individual Port(s) | Assignee: | freebsd-ports-bugs (Nobody) <ports-bugs> | ||||||
| Status: | Closed FIXED | ||||||||
| Severity: | Affects Only Me | CC: | kib, nobutaka, ultima, yuri | ||||||
| Priority: | --- | Keywords: | crash, needs-qa | ||||||
| Version: | Latest | Flags: | bugzilla:
maintainer-feedback?
(yuri) |
||||||
| Hardware: | Any | ||||||||
| OS: | Any | ||||||||
| Attachments: |
|
||||||||
|
Description
Jan Beich
2017-06-30 12:18:31 UTC
Adding /lib/libthr.so.3 to LD_PRELOAD makes the crash go away. w3m is already linked against libthr.so.3 but torsocks isn't, so FLOCKFILE_CANCELSAFE() probably ends up using pthread stubs. (In reply to Jan Beich from comment #1) No, the normal libthr clean code is bound, and this is the problem since libthr is not yet initialized due to LD_PRELOAD causing the libtorsocks.so to stay out of normal initialization order. Try the patch, only libthr.so needs to be rebuild. Created attachment 183939 [details]
Initialize libthr if cleanup handler is called.
Comment on attachment 183939 [details]
Initialize libthr if cleanup handler is called.
Assertion failed: (!ret), function tsocks_mutex_unlock, file compat.c, line 72.
Program received signal SIGABRT, Aborted.
thr_kill () at thr_kill.S:3
3 RSYSCALL(thr_kill)
(gdb) bt
#0 thr_kill () at thr_kill.S:3
#1 0x0000000801ff7ff4 in __raise (s=6) at /usr/src/lib/libc/gen/raise.c:52
#2 0x0000000801ff7f69 in abort () at /usr/src/lib/libc/stdlib/abort.c:65
#3 0x000000080207b1f1 in __assert (func=<optimized out>, file=<optimized out>,
line=<optimized out>, failedexpr=<optimized out>) at /usr/src/lib/libc/gen/assert.c:51
#4 0x00000008008fa1c3 in tsocks_mutex_unlock (m=0x800b047d0 <init_once+8>) at compat.c:72
#5 0x00000008008fa2a0 in tsocks_once (o=0x800b047c8 <init_once>,
init_routine=0x8008f20b0 <tsocks_init>) at compat.c:97
#6 0x00000008008f2089 in tsocks_initialize () at torsocks.c:702
#7 0x00000008008feea2 in __do_global_ctors_aux () from /usr/local/lib/torsocks/libtorsocks.so
#8 0x00000008008f0c96 in _init () from /usr/local/lib/torsocks/libtorsocks.so
#9 0x00007fffffffe220 in ?? ()
#10 0x00000008006ce8a8 in objlist_call_init (list=<optimized out>, lockstate=<optimized out>)
at rtld.c:2633
#11 0x00000008006cd9ec in _rtld (sp=0x7fffffffed50, exit_proc=<optimized out>,
objp=<optimized out>) at rtld.c:759
#12 0x00000008006cb669 in .rtld_start () at /usr/src/libexec/rtld-elf/amd64/rtld_start.S:39
#13 0x0000000000000000 in ?? ()
(gdb) f 4
#4 0x00000008008fa1c3 in tsocks_mutex_unlock (m=0x800b047d0 <init_once+8>) at compat.c:72
72 assert(!ret);
(gdb) l
67 ret = pthread_mutex_unlock(&m->mutex);
68 /*
69 * Unable to unlock the mutex could lead to undefined behavior and potential
70 * security issues. Stop everything so torsocks can't continue.
71 */
72 assert(!ret);
73 }
74
75 /*
76 * Call the given routine once, and only once. tsocks_once returning
Created attachment 183949 [details]
Try harder to call libc stubs for cleanup push/pop_imp, if libthr still not yet initialized.
Comment on attachment 183949 [details]
Try harder to call libc stubs for cleanup push/pop_imp, if libthr still not yet initialized.
Thank you. With this version torsocks no longer crashes here.
A commit references this bug: Author: kib Date: Fri Jun 30 20:27:52 UTC 2017 New revision: 320509 URL: https://svnweb.freebsd.org/changeset/base/320509 Log: In the stdio cleanup push and pop wrappers, always call libc stubs for __pthread_cleanup_push/pop_imp instead of symbols also exported from libthr. This prevents calls into libthr if libthr is not yet initialized. The situation occurs e.g. when an LD_PRELOADed object is not linked against libthr, but the main binary is. Reported and tested by: jbeich PR: 220381 Discussed with: vangyzen Sponsored by: The FreeBSD Foundation MFC after: 13 days Changes: head/lib/libc/include/libc_private.h head/lib/libc/stdio/local.h It looks like no action is required in the torsocks port itself. Looks like this has been resolved, closing PR. |