@ortadur: "Hi,
I'm new to FreeBSD and I'm running into a lot of core dumps (mainly from Xorg, but also from vim, firefox, ...).
That's why I asked on freebsd-questions:
<url>
<url>
The last Xorg crash was less than 2h ago. :(
It looks like that there is a missing check for NULL in lib/libkse/thread/thr_spec.c (line 211-214):
    pthread = _get_curthread();
    /* Check if there is specific data: */
    if (pthread->specific != NULL && (unsigned int)key < PTHREAD_KEYS_MAX) {
If pthread is NULL it will core dump. So maybe something like this would help:
    if (pthread != NULL && pthread->specific != NULL && (unsigned int)key < PTHREAD_KEYS_MAX) {
But as I'm said, I'm new to FreeBSD I can't evaluate it yet.
I'm running the most recent stable:
% uname -a
FreeBSD andre 10.1-RELEASE-p10 FreeBSD 10.1-RELEASE-p10 #0: Wed May 13 06:54:13 UTC 2015
I haven't compiled the base system so far. Maybe a more experienced FreeBSD guy can verify this and decide if it makes any sense or if I have to dig any deeper into it.
Sincerely yours Andre.
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @ortadur: "<quote>
Thank you, that was exactly what I was looking for. Now I like FreeBSD even more. ;)
I made this short after and also rebooted the entire system to make all programmes use those debug libs. Since than I had not a single core dump.
I experienced something similar in the past, that with activated debugging some errors can't be triggered any longer.
At the moment I'm happy without crashes and I can work with this system. As soon as I'm getting a new core dump, I'll post the backtrace. If this won't happen for weeks, I may recompile the libs again, try to find a way to trigger the bug on purpose, enable the debug flag again and than provide the info.
In the meantime, maybe a core developer may think about the lines of code I'd provided. Why is _get_curthread() compared to NULL at thr_kern.c (line 601) but not at thr_spec.c (line 224)? Either _get_curthread() never ever returns NULL, than it's pointless to test it or it's missing [not only] at thr_spec.c.
I'm using activated hyperthreading:
% sysctl hw.model hw.machine hw.ncpu
hw.model: Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz
hw.machine: amd64
hw.ncpu: 8
Sincerely yours Andre.
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @kostikbel: "<quote>
Which means, most likely, that your installation was corrupted.
Whole thr_kern.c file is 213 lines long in the HEAD.
Might be, a core developer has a 601-lines long thr_kern.c.
The only way for _get_curthread() to return NULL or, more likely, a
garbage, is for the call to _get_curthread() to happens before the
threading machinery was initialized. WRT the thr_spec.c, correct code
must call pthread_key_create(3) at least once before calling any other
pthread_key_*(3) functions. The implementation of pthread_key_create(3)
interface, the function _pthread_key_create(), calls _thr_check_init()
as the first action, and this helper initializes threading. So if
_get_curthread() in any pthread_key_*() function returns NULL or
garbage, this is an application' bug.
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @gpalmer: "<quote>
lib/libkse/thread/thr_kern.c is longer and has a 
_get_curthread() call around line 601.
Regards,
Gary
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @ortadur: "<quote>
% ldd /usr/local/bin/vim
/usr/local/bin/vim:
	libm.so.5 => /lib/libm.so.5 (0x800a55000)
	libncurses.so.8 => /lib/libncurses.so.8 (0x800c7d000)
	libintl.so.8 => /usr/local/lib/libintl.so.8 (0x800eca000)
	libpython2.7.so.1 => /usr/local/lib/libpython2.7.so.1 (0x8010d5000)
	libthr.so.3 => /lib/libthr.so.3 (0x801490000)
	libc.so.7 => /lib/libc.so.7 (0x8016b5000)
	libutil.so.9 => /lib/libutil.so.9 (0x801a5e000)
% readelf -d /usr/local/bin/vim | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libncurses.so.8]
 0x0000000000000001 (NEEDED)             Shared library: [libintl.so.8]
 0x0000000000000001 (NEEDED)             Shared library: [libpython2.7.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libthr.so.3]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.7]
Vim is compiled with CSCOPE, DEFAULT_VIMRC, EXUBERANT_CTAGS, NLS, PYTHON and CONSOLE.
This vim core dump remains the only one since the recompilation of libc and libthr with debug flag.
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @kostikbel: "<quote>
Ok, so the vim fault is reproducable, I suppose ?
info locals
info registers
disassemble
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @ortadur: "Hi,
back again. Sorry, I accidently deleted the core file and I'd to wait two weeks until vim crashed again. Xorg didn't crashed so far with the debug libs.
<quote>
No, I tried, but no chance to do it on purpose. But so far it always happens while resizing the xterm.
Now the entire info you asked for (out of the new core file):
% readelf -d vim | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libncurses.so.8]
 0x0000000000000001 (NEEDED)             Shared library: [libintl.so.8]
 0x0000000000000001 (NEEDED)             Shared library: [libpython2.7.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libthr.so.3]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.7]
(gdb) bt
#0  0x000000080149e6a2 in check_deferred_signal (curthread=0x802406400) at /usr/src/lib/libthr/thread/thr_sig.c:331
#1  0x000000080149e5ed in _thr_ast (curthread=0x802406400) at /usr/src/lib/libthr/thread/thr_sig.c:264
#2  0x00000008014a33c7 in _thr_rtld_lock_release (lock=<value optimized out>) at /usr/src/lib/libthr/thread/thr_rtld.c:162
#3  0x000000080083d94d in _r_debug_postinit () from /libexec/ld-elf.so.1
#4  0x000000080083b15d in .text () from /libexec/ld-elf.so.1
#5  0x00000000004e4163 in preserve_exit ()
#6  0x000000000051f118 in mch_libcall ()
#7  0x000000080149f47a in handle_signal (actp=<value optimized out>, sig=<value optimized out>, info=<value optimized out>, ucp=<value optimized out>) at /usr/src/lib/libthr/thread/thr_sig.c:240
#8  0x000000080149f062 in thr_sighandler (sig=<value optimized out>, info=<value optimized out>, _ucp=<value optimized out>) at /usr/src/lib/libthr/thread/thr_sig.c:183
#9  <signal handler called>
#10 0x000000080149e6a2 in check_deferred_signal (curthread=0x802406400) at /usr/src/lib/libthr/thread/thr_sig.c:331
#11 0x000000080149e5ed in _thr_ast (curthread=0x802406400) at /usr/src/lib/libthr/thread/thr_sig.c:264
#12 0x00000008014a33c7 in _thr_rtld_lock_release (lock=<value optimized out>) at /usr/src/lib/libthr/thread/thr_rtld.c:162
#13 0x000000080083d94d in _r_debug_postinit () from /libexec/ld-elf.so.1
#14 0x000000080083b15d in .text () from /libexec/ld-elf.so.1
#15 0x000000080149f4e2 in handle_signal (actp=<value optimized out>, sig=<value optimized out>, info=<value optimized out>, ucp=<value optimized out>) at /usr/src/lib/libthr/thread/thr_sig.c:256
#16 0x000000080149f062 in thr_sighandler (sig=<value optimized out>, info=<value optimized out>, _ucp=<value optimized out>) at /usr/src/lib/libthr/thread/thr_sig.c:183
#17 <signal handler called>
#18 select () at select.S:3
#19 0x000000080149cb32 in __select (numfds=1, readfds=0x7fffffffdfb0, writefds=0x0, exceptfds=0x7fffffffdf30, timeout=0x7fffffffe038) at /usr/src/lib/libthr/thread/thr_syscalls.c:561
#20 0x000000000051ac4b in mch_write ()
#21 0x000000000051ae0f in mch_inchar ()
#22 0x00000000005b8647 in ui_inchar ()
#23 0x00000000004aeb8a in inchar ()
#24 0x00000000004b1ffb in vgetc ()
#25 0x00000000004b0efa in vgetc ()
#26 0x00000000004b27b9 in safe_vgetc ()
#27 0x00000000004f59ef in normal_cmd ()
#28 0x00000000005dfec7 in main_loop ()
#29 0x00000000005df538 in main ()
(gdb) info locals
act = {__sigaction_u = {__sa_handler = 0, __sa_sigaction = 0}, sa_flags = 37875000, sa_mask = {__bits = {8, 4239276, 0, 0}}}
info = {si_signo = 0, si_errno = 0, si_code = 37875000, si_pid = 8, si_uid = 37874640, si_status = 8, si_addr = 0x700000008, si_value = {sival_int = 37875104, sival_ptr = 0x80241eda0, sigval_int = 37875104, sigval_ptr = 0x80241eda0}, _reason = {_fault = {_trapno = 141}, 
    _timer = {_timerid = 141, _overrun = 0}, _mesgq = {_mqd = 141}, _poll = {_band = 141}, __spare__ = {__spare1__ = 141, __spare2__ = {0, 0, 8744960, 8, 37874976, 8, 8641467}}}}
(gdb) info registers
rax            0xf0b470 15774832
rbx            0x802406400      34397512704
rcx            0x1      1
rdx            0x80085b800      34368501760
rsi            0x80241ed38      34397613368
rdi            0x8015137d0      34381838288
rbp            0x80241ecd0      0x80241ecd0
rsp            0x8015137d0      0x8015137d0
r8             0x800856600      34368480768
r9             0x8080808080808080       -9187201950435737472
r10            0x41b778 4306808
r11            0x5262   21090
r12            0x1      1
r13            0x839888 8624264
r14            0x8015137d0      34381838288
r15            0x2      2
rip            0x80149e6a2      0x80149e6a2 <check_deferred_signal+82>
eflags         0x10202  66050
cs             0x43     67
ss             0x3b     59
ds             0x0      0
es             0x0      0
fs             0x0      0
gs             0x0      0
(gdb) disassemble
Dump of assembler code for function check_deferred_signal:
0x000000080149e650 <check_deferred_signal+0>:   push   %rbp
0x000000080149e651 <check_deferred_signal+1>:   mov    %rsp,%rbp
0x000000080149e654 <check_deferred_signal+4>:   push   %r15
0x000000080149e656 <check_deferred_signal+6>:   push   %r14
0x000000080149e658 <check_deferred_signal+8>:   push   %rbx
0x000000080149e659 <check_deferred_signal+9>:   sub    $0x78,%rsp
0x000000080149e65d <check_deferred_signal+13>:  mov    %rdi,%rbx
0x000000080149e660 <check_deferred_signal+16>:  cmpl   $0x0,0x100(%rbx)
0x000000080149e667 <check_deferred_signal+23>:  je     0x80149e672 <check_deferred_signal+34>
0x000000080149e669 <check_deferred_signal+25>:  cmpl   $0x0,0x180(%rbx)
0x000000080149e670 <check_deferred_signal+32>:  je     0x80149e67d <check_deferred_signal+45>
0x000000080149e672 <check_deferred_signal+34>:  lea    -0x18(%rbp),%rsp
0x000000080149e676 <check_deferred_signal+38>:  pop    %rbx
0x000000080149e677 <check_deferred_signal+39>:  pop    %r14
0x000000080149e679 <check_deferred_signal+41>:  pop    %r15
0x000000080149e67b <check_deferred_signal+43>:  pop    %rbp
0x000000080149e67c <check_deferred_signal+44>:  retq   
0x000000080149e67d <check_deferred_signal+45>:  movl   $0x1,0x180(%rbx)
0x000000080149e687 <check_deferred_signal+55>:  callq  0x801498e44 <__getcontextx_size@plt>
0x000000080149e68c <check_deferred_signal+60>:  cltq   
0x000000080149e68e <check_deferred_signal+62>:  mov    %rsp,%r14
0x000000080149e691 <check_deferred_signal+65>:  add    $0xf,%rax
0x000000080149e695 <check_deferred_signal+69>:  and    $0xfffffffffffffff0,%rax
0x000000080149e699 <check_deferred_signal+73>:  sub    %rax,%r14
0x000000080149e69c <check_deferred_signal+76>:  mov    %r14,%rsp
0x000000080149e69f <check_deferred_signal+79>:  mov    %r14,%rdi
0x000000080149e6a2 <check_deferred_signal+82>:  callq  0x801499214 <getcontext@plt>
0x000000080149e6a7 <check_deferred_signal+87>:  cmpl   $0x0,0x100(%rbx)
0x000000080149e6ae <check_deferred_signal+94>:  je     0x80149e73b <check_deferred_signal+235>
0x000000080149e6b4 <check_deferred_signal+100>: lea    0x100(%rbx),%r15
0x000000080149e6bb <check_deferred_signal+107>: mov    %r14,%rdi
0x000000080149e6be <check_deferred_signal+110>: callq  0x801499064 <__fillcontextx2@plt>
0x000000080149e6c3 <check_deferred_signal+115>: movups 0x160(%rbx),%xmm0
0x000000080149e6ca <check_deferred_signal+122>: movups 0x170(%rbx),%xmm1
0x000000080149e6d1 <check_deferred_signal+129>: movaps %xmm1,-0x30(%rbp)
0x000000080149e6d5 <check_deferred_signal+133>: movaps %xmm0,-0x40(%rbp)
0x000000080149e6d9 <check_deferred_signal+137>: movups 0x150(%rbx),%xmm0
0x000000080149e6e0 <check_deferred_signal+144>: movups %xmm0,(%r14)
0x000000080149e6e4 <check_deferred_signal+148>: movups 0x40(%r15),%xmm0
0x000000080149e6e9 <check_deferred_signal+153>: movaps %xmm0,-0x50(%rbp)
0x000000080149e6ed <check_deferred_signal+157>: movups (%r15),%xmm0
0x000000080149e6f1 <check_deferred_signal+161>: movups 0x10(%r15),%xmm1
0x000000080149e6f6 <check_deferred_signal+166>: movups 0x20(%r15),%xmm2
0x000000080149e6fb <check_deferred_signal+171>: movups 0x30(%r15),%xmm3
0x000000080149e700 <check_deferred_signal+176>: movaps %xmm3,-0x60(%rbp)
0x000000080149e704 <check_deferred_signal+180>: movaps %xmm2,-0x70(%rbp)
0x000000080149e708 <check_deferred_signal+184>: movaps %xmm1,-0x80(%rbp)
0x000000080149e70c <check_deferred_signal+188>: movaps %xmm0,-0x90(%rbp)
0x000000080149e713 <check_deferred_signal+195>: movl   $0x0,0x100(%rbx)
0x000000080149e71d <check_deferred_signal+205>: mov    -0x90(%rbp),%esi
0x000000080149e723 <check_deferred_signal+211>: lea    -0x40(%rbp),%rdi
0x000000080149e727 <check_deferred_signal+215>: lea    -0x90(%rbp),%rdx
0x000000080149e72e <check_deferred_signal+222>: mov    %r14,%rcx
0x000000080149e731 <check_deferred_signal+225>: callq  0x80149f390 <handle_signal>
0x000000080149e736 <check_deferred_signal+230>: jmpq   0x80149e672 <check_deferred_signal+34>
0x000000080149e73b <check_deferred_signal+235>: movl   $0x0,0x180(%rbx)
0x000000080149e745 <check_deferred_signal+245>: jmpq   0x80149e672 <check_deferred_signal+34>
End of assembler dump.
I've kept a copy of the vim binary and also the core file, so this time I can answer any further questions much faster. ;)
I can't help much with those assembler part. But I've looked into /usr/src/lib/libthr/thread/thr_sig.c and there is alloca used at line 330:
   330      uc = alloca(uc_len);
   331      getcontext(uc);
I would bet using malloc and check for NULL will help to fix this problem. Well, there will be a free needed before return and one at the end of check_deferred_signal, but that's better than an unsafe alloca.
Sincerely yours Andre.
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @ortadur: "<quote>
Wow, I should start learning how to dig into those core dumps...
I've patched my system.  I can't reproduce the bug, and it took a long time to trigger that bug again the last time.  If it crashes again, I'll post the entire debug info.  And if not, I'll write it to you next month.
Thanks for the patch.
Sincerely yours Andre.
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @ortadur: "Hi,
no crash from vim or Xorg but from xterm and again at getcontext(uc) after alloca:
% readelf -d xterm | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libXinerama.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libXft.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libfontconfig.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libutil.so.9]
 0x0000000000000001 (NEEDED)             Shared library: [libXaw.so.7]
 0x0000000000000001 (NEEDED)             Shared library: [libXmu.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libXt.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libX11.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libXpm.so.4]
 0x0000000000000001 (NEEDED)             Shared library: [libICE.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libulog.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libncurses.so.8]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.7]
(gdb) bt
#0  0x0000000803038642 in check_deferred_signal (curthread=0x805006400)
    at /usr/src/lib/libthr/thread/thr_sig.c:332
#1  0x000000080303858d in _thr_ast (curthread=0x805006400)
    at /usr/src/lib/libthr/thread/thr_sig.c:265
#2  0x000000080303d367 in _thr_rtld_lock_release (lock=<value optimized out>)
    at /usr/src/lib/libthr/thread/thr_rtld.c:162
#3  0x000000080067d94d in _r_debug_postinit () from /libexec/ld-elf.so.1
#4  0x000000080067b15d in .text () from /libexec/ld-elf.so.1
#5  0x0000000000438007 in ?? ()
#6  0x000000000043fe77 in ?? ()
#7  0x000000000041808b in ?? ()
#8  0x0000000000417e0a in ?? ()
#9  0x000000000042e04a in ?? ()
#10 0x000000000040823f in ?? ()
#11 0x0000000800697000 in ?? ()
#12 0x0000000000000000 in ?? ()
(gdb) info locals
act = {__sigaction_u = {__sa_handler = 0x7fff00000001, 
    __sa_sigaction = 0x7fff00000001}, sa_flags = -6472, sa_mask = {__bits = {
      32767, 4198068, 0, 54936355}}}
info = {si_signo = 0, si_errno = 0, si_code = -6472, si_pid = 32767, 
  si_uid = 4294960256, si_status = 32767, si_addr = 0x800000021, si_value = {
    sival_int = -6368, sival_ptr = 0x7fffffffe720, sigval_int = -6368, 
    sigval_ptr = 0x7fffffffe720}, _reason = {_fault = {_trapno = 15}, 
    _timer = {_timerid = 15, _overrun = 0}, _mesgq = {_mqd = 15}, _poll = {
      _band = 15}, __spare__ = {__spare1__ = 15, __spare2__ = {0, 0, 6909952, 
        8, -6496, 32767, 6806459}}}}
(gdb) info registers
rax            0xf0b470 15774832
rbx            0x805006400      34443650048
rcx            0x0      0
rdx            0xca0000 13238272
rsi            0x7fffffffe6b8   140737488348856
rdi            0x7fffff0f3150   140737472573776
rbp            0x7fffffffe650   0x7fffffffe650
rsp            0x7fffff0f3150   0x7fffff0f3150
r8             0x12     18
r9             0x7fffffffe720   140737488348960
r10            0x4030d0 4206800
r11            0x261    609
r12            0x1      1
r13            0x679320 6787872
r14            0x7fffff0f3150   140737472573776
r15            0x23     35
rip            0x803038642      0x803038642 <check_deferred_signal+82>
eflags         0x10206  66054
cs             0x43     67
ss             0x3b     59
ds             0x0      0
es             0x0      0
fs             0x0      0
gs             0x0      0
(gdb) disassemble
Dump of assembler code for function check_deferred_signal:
0x00000008030385f0 <check_deferred_signal+0>:   push   %rbp
0x00000008030385f1 <check_deferred_signal+1>:   mov    %rsp,%rbp
0x00000008030385f4 <check_deferred_signal+4>:   push   %r15
0x00000008030385f6 <check_deferred_signal+6>:   push   %r14
0x00000008030385f8 <check_deferred_signal+8>:   push   %rbx
0x00000008030385f9 <check_deferred_signal+9>:   sub    $0x78,%rsp
0x00000008030385fd <check_deferred_signal+13>:  mov    %rdi,%rbx
0x0000000803038600 <check_deferred_signal+16>:  cmpl   $0x0,0x100(%rbx)
0x0000000803038607 <check_deferred_signal+23>:  je     0x803038612 <check_deferred_signal+34>
0x0000000803038609 <check_deferred_signal+25>:  cmpl   $0x0,0x180(%rbx)
0x0000000803038610 <check_deferred_signal+32>:  je     0x80303861d <check_deferred_signal+45>
0x0000000803038612 <check_deferred_signal+34>:  lea    -0x18(%rbp),%rsp
0x0000000803038616 <check_deferred_signal+38>:  pop    %rbx
0x0000000803038617 <check_deferred_signal+39>:  pop    %r14
0x0000000803038619 <check_deferred_signal+41>:  pop    %r15
0x000000080303861b <check_deferred_signal+43>:  pop    %rbp
0x000000080303861c <check_deferred_signal+44>:  retq   
0x000000080303861d <check_deferred_signal+45>:  movl   $0x1,0x180(%rbx)
0x0000000803038627 <check_deferred_signal+55>:  callq  0x803032dfc <__getcontextx_size@plt>
0x000000080303862c <check_deferred_signal+60>:  cltq   
0x000000080303862e <check_deferred_signal+62>:  mov    %rsp,%r14
0x0000000803038631 <check_deferred_signal+65>:  add    $0xf,%rax
0x0000000803038635 <check_deferred_signal+69>:  and    $0xfffffffffffffff0,%rax
0x0000000803038639 <check_deferred_signal+73>:  sub    %rax,%r14
0x000000080303863c <check_deferred_signal+76>:  mov    %r14,%rsp
0x000000080303863f <check_deferred_signal+79>:  mov    %r14,%rdi
0x0000000803038642 <check_deferred_signal+82>:  callq  0x8030331cc <getcontext@plt>
0x0000000803038647 <check_deferred_signal+87>:  cmpl   $0x0,0x100(%rbx)
0x000000080303864e <check_deferred_signal+94>:  je     0x8030386db <check_deferred_signal+235>
0x0000000803038654 <check_deferred_signal+100>: lea    0x100(%rbx),%r15
0x000000080303865b <check_deferred_signal+107>: mov    %r14,%rdi
0x000000080303865e <check_deferred_signal+110>: callq  0x80303301c <__fillcontextx2@plt>
0x0000000803038663 <check_deferred_signal+115>: movups 0x160(%rbx),%xmm0
0x000000080303866a <check_deferred_signal+122>: movups 0x170(%rbx),%xmm1
0x0000000803038671 <check_deferred_signal+129>: movaps %xmm1,-0x30(%rbp)
0x0000000803038675 <check_deferred_signal+133>: movaps %xmm0,-0x40(%rbp)
0x0000000803038679 <check_deferred_signal+137>: movups 0x150(%rbx),%xmm0
0x0000000803038680 <check_deferred_signal+144>: movups %xmm0,(%r14)
0x0000000803038684 <check_deferred_signal+148>: movups 0x40(%r15),%xmm0
0x0000000803038689 <check_deferred_signal+153>: movaps %xmm0,-0x50(%rbp)
0x000000080303868d <check_deferred_signal+157>: movups (%r15),%xmm0
0x0000000803038691 <check_deferred_signal+161>: movups 0x10(%r15),%xmm1
0x0000000803038696 <check_deferred_signal+166>: movups 0x20(%r15),%xmm2
0x000000080303869b <check_deferred_signal+171>: movups 0x30(%r15),%xmm3
0x00000008030386a0 <check_deferred_signal+176>: movaps %xmm3,-0x60(%rbp)
0x00000008030386a4 <check_deferred_signal+180>: movaps %xmm2,-0x70(%rbp)
0x00000008030386a8 <check_deferred_signal+184>: movaps %xmm1,-0x80(%rbp)
0x00000008030386ac <check_deferred_signal+188>: movaps %xmm0,-0x90(%rbp)
0x00000008030386b3 <check_deferred_signal+195>: movl   $0x0,0x100(%rbx)
0x00000008030386bd <check_deferred_signal+205>: mov    -0x90(%rbp),%esi
0x00000008030386c3 <check_deferred_signal+211>: lea    -0x40(%rbp),%rdi
0x00000008030386c7 <check_deferred_signal+215>: lea    -0x90(%rbp),%rdx
0x00000008030386ce <check_deferred_signal+222>: mov    %r14,%rcx
0x00000008030386d1 <check_deferred_signal+225>: callq  0x803039330 <handle_signal>
0x00000008030386d6 <check_deferred_signal+230>: jmpq   0x803038612 <check_deferred_signal+34>
0x00000008030386db <check_deferred_signal+235>: movl   $0x0,0x180(%rbx)
0x00000008030386e5 <check_deferred_signal+245>: jmpq   0x803038612 <check_deferred_signal+34>
End of assembler dump.
I like the system, but this thread library smells fishy... :(
Sincerely yours Andre.
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @kostikbel: "<quote>
It seems that besides sigreturn(), ucontext symbols must be pre-resolved
as well.  Try this update (it includes the previous change).
diff git a/lib/libthr/thread/thr_rtld.c b/lib/libthr/thread/thr_rtld.c
index 5d89988..cb20098 100644
- a/lib/libthr/thread/thr_rtld.c
+++ b/lib/libthr/thread/thr_rtld.c
@@ -185,7 +185,9 @@ _thr_rtld_init(void)
 {
 	struct RtldLockInfo	li;
 	struct pthread		*curthread;
+	ucontext_t *uc;
 	long dummy = -1;
+	int uc_len;
 	curthread = _get_curthread();
@@ -231,4 +233,9 @@ _thr_rtld_init(void)
 	_thr_signal_block(curthread);
 	_rtld_thread_init(&li);
 	_thr_signal_unblock(curthread);
+
+	uc_len = __getcontextx_size();
+	uc = alloca(uc_len);
+	getcontext(uc);
+	__fillcontextx2((char *)uc);
 }
diff git a/lib/libthr/thread/thr_sig.c b/lib/libthr/thread/thr_sig.c
index a6d021f..ebb6c58 100644
- a/lib/libthr/thread/thr_sig.c
+++ b/lib/libthr/thread/thr_sig.c
@@ -30,6 +30,7 @@
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/signalvar.h>
+#include <sys/syscall.h>
 #include <signal.h>
 #include <errno.h>
 #include <stdlib.h>
@@ -257,7 +258,7 @@ handle_signal(struct sigaction *actp, int sig, siginfo_t *info, ucontext_t *ucp)
 	/* reschedule cancellation */
 	check_cancel(curthread, &uc2);
 	errno = err;
-	__sys_sigreturn(&uc2);
+	syscall(SYS_sigreturn, &uc2);
 }
 void
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @ortadur: "<quote>
thanks for looking into this, but this patch wasn't janderson@example.net.  Did you tested your patch?  Almost every programme crashed with a core dump.  Here the example for simply starting vim:
% readelf -d vim | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libncurses.so.8]
 0x0000000000000001 (NEEDED)             Shared library: [libintl.so.8]
 0x0000000000000001 (NEEDED)             Shared library: [libpython2.7.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libthr.so.3]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.7]
(gdb) bt
#0  0x00000008014a30d4 in _thr_rtld_init () at /usr/src/lib/libthr/thread/thr_rtld.c:239
#1  0x00000008014a2f03 in _libpthread_init (curthread=<value optimized out>) at /usr/src/lib/libthr/thread/thr_init.c:372
#2  0x00000008014a5c22 in _thread_printf () from /lib/libthr.so.3
#3  0x0000000801498d06 in _init () from /lib/libthr.so.3
#4  0x00007fffffffe000 in ?? ()
#5  0x000000080083d6bf in r_debug_state () from /libexec/ld-elf.so.1
#6  0x000000080083cd17 in __tls_get_addr () from /libexec/ld-elf.so.1
#7  0x000000080083b129 in .text () from /libexec/ld-elf.so.1
#8  0x0000000000000000 in ?? ()
(gdb) info locals
li = {rtli_version = 0, lock_create = 0x8014a30f0 <_thr_rtld_lock_create>, lock_destroy = 0x8014a3160 <_thr_rtld_lock_destroy>,
  rlock_acquire = 0x8014a31b0 <_thr_rtld_rlock_acquire>, wlock_acquire = 0x8014a3270 <_thr_rtld_wlock_acquire>,
  lock_release = 0x8014a3300 <_thr_rtld_lock_release>, thread_set_flag = 0x8014a33c0 <_thr_rtld_set_flag>,
  thread_clr_flag = 0x8014a33d0 <_thr_rtld_clr_flag>, at_fork = 0}
dummy = -1
curthread = (struct pthread *) 0x7fffff0f2650
uc_len = <value optimized out
(gdb) info registers
rax            0xf0b470 15774832
rbx            0x7fffff0f2650   140737472570960
rcx            0x0  0
rdx            0xca0000 13238272
rsi            0x8024064e8  34397512936
rdi            0x7fffff0f2650   140737472570960
rbp            0x7fffffffdb20   0x7fffffffdb20
rsp            0x7fffff0f2650   0x7fffff0f2650
r8             0x0  0
r9             0xfffff8000e35f4c0   -8795854605120
r10            0x0  0
r11            0x246    582
r12            0x800a54a28  34370570792
r13            0x800a545b0  34370569648
r14            0x1  1
r15            0x800855420  34368476192
rip            0x8014a30d4  0x8014a30d4 <_thr_rtld_init+244>
eflags         0x10206  66054
cs             0x43 67
ss             0x3b 59
ds             0x0  0
es             0x0  0
fs             0x0  0
gs             0x0  0
(gdb) disassemble
Dump of assembler code for function _thr_rtld_init:
0x00000008014a2fe0 <_thr_rtld_init+0>:  push   %rbp
0x00000008014a2fe1 <_thr_rtld_init+1>:  mov    %rsp,%rbp
0x00000008014a2fe4 <_thr_rtld_init+4>:  push   %rbx
0x00000008014a2fe5 <_thr_rtld_init+5>:  sub    $0x58,%rsp
0x00000008014a2fe9 <_thr_rtld_init+9>:  movq   $0xffffffffffffffff,-0x58(%rbp)
0x00000008014a2ff1 <_thr_rtld_init+17>: mov    %fs:0x10,%rbx
0x00000008014a2ffa <_thr_rtld_init+26>: lea    -0x58(%rbp),%rdi
0x00000008014a2ffe <_thr_rtld_init+30>: mov    $0x3,%esi
0x00000008014a3003 <_thr_rtld_init+35>: mov    $0x1,%edx
0x00000008014a3008 <_thr_rtld_init+40>: xor    %ecx,%ecx
0x00000008014a300a <_thr_rtld_init+42>: xor    %r8d,%r8d
0x00000008014a300d <_thr_rtld_init+45>: callq  0x8014a5890 <_umtx_op_err>
0x00000008014a3012 <_thr_rtld_init+50>: callq  0x80149916c <__error@plt>
0x00000008014a3017 <_thr_rtld_init+55>: xor    %edi,%edi
0x00000008014a3019 <_thr_rtld_init+57>: xor    %esi,%esi
0x00000008014a301b <_thr_rtld_init+59>: xor    %edx,%edx
0x00000008014a301d <_thr_rtld_init+61>: callq  0x8014990ac <mprotect@plt>
0x00000008014a3022 <_thr_rtld_init+66>: callq  0x8014991ac <_rtld_get_stack_prot@plt>
0x00000008014a3027 <_thr_rtld_init+71>: lea    0xc2(%rip),%rax        # 0x8014a30f0 <_thr_rtld_lock_create>
0x00000008014a302e <_thr_rtld_init+78>: mov    %rax,-0x48(%rbp)
0x00000008014a3032 <_thr_rtld_init+82>: lea    0x127(%rip),%rax        # 0x8014a3160 <_thr_rtld_lock_destroy>
0x00000008014a3039 <_thr_rtld_init+89>: mov    %rax,-0x40(%rbp)
0x00000008014a303d <_thr_rtld_init+93>: lea    0x16c(%rip),%rax        # 0x8014a31b0 <_thr_rtld_rlock_acquire>
0x00000008014a3044 <_thr_rtld_init+100>:    mov    %rax,-0x38(%rbp)
0x00000008014a3048 <_thr_rtld_init+104>:    lea    0x221(%rip),%rax        # 0x8014a3270 <_thr_rtld_wlock_acquire>
0x00000008014a304f <_thr_rtld_init+111>:    mov    %rax,-0x30(%rbp)
0x00000008014a3053 <_thr_rtld_init+115>:    lea    0x2a6(%rip),%rax        # 0x8014a3300 <_thr_rtld_lock_release>
0x00000008014a305a <_thr_rtld_init+122>:    mov    %rax,-0x28(%rbp)
0x00000008014a305e <_thr_rtld_init+126>:    lea    0x35b(%rip),%rax        # 0x8014a33c0 <_thr_rtld_set_flag>
0x00000008014a3065 <_thr_rtld_init+133>:    mov    %rax,-0x20(%rbp)
0x00000008014a3069 <_thr_rtld_init+137>:    lea    0x360(%rip),%rax        # 0x8014a33d0 <_thr_rtld_clr_flag>
0x00000008014a3070 <_thr_rtld_init+144>:    mov    %rax,-0x18(%rbp)
0x00000008014a3074 <_thr_rtld_init+148>:    movq   $0x0,-0x10(%rbp)
0x00000008014a307c <_thr_rtld_init+156>:    xor    %edi,%edi
0x00000008014a307e <_thr_rtld_init+158>:    callq  0x8014991dc <_rtld_atfork_pre@plt>
0x00000008014a3083 <_thr_rtld_init+163>:    xor    %edi,%edi
0x00000008014a3085 <_thr_rtld_init+165>:    callq  0x801498dbc <_rtld_atfork_post@plt>
0x00000008014a308a <_thr_rtld_init+170>:    callq  0x801498e3c <_malloc_prefork@plt>
0x00000008014a308f <_thr_rtld_init+175>:    callq  0x80149919c <_malloc_postfork@plt>
0x00000008014a3094 <_thr_rtld_init+180>:    mov    $0x14,%edi
0x00000008014a3099 <_thr_rtld_init+185>:    xor    %eax,%eax
0x00000008014a309b <_thr_rtld_init+187>:    callq  0x8014990fc <syscall@plt>
0x00000008014a30a0 <_thr_rtld_init+192>:    mov    %rbx,%rdi
0x00000008014a30a3 <_thr_rtld_init+195>:    callq  0x80149e4f0 <_thr_signal_block>
0x00000008014a30a8 <_thr_rtld_init+200>:    lea    -0x50(%rbp),%rdi
0x00000008014a30ac <_thr_rtld_init+204>:    callq  0x801498f3c <_rtld_thread_init@plt>
0x00000008014a30b1 <_thr_rtld_init+209>:    mov    %rbx,%rdi
0x00000008014a30b4 <_thr_rtld_init+212>:    callq  0x80149e530 <_thr_signal_unblock>
0x00000008014a30b9 <_thr_rtld_init+217>:    callq  0x801498dfc <__getcontextx_size@plt>
0x00000008014a30be <_thr_rtld_init+222>:    cltq
0x00000008014a30c0 <_thr_rtld_init+224>:    mov    %rsp,%rbx
0x00000008014a30c3 <_thr_rtld_init+227>:    add    $0xf,%rax
0x00000008014a30c7 <_thr_rtld_init+231>:    and    $0xfffffffffffffff0,%rax
0x00000008014a30cb <_thr_rtld_init+235>:    sub    %rax,%rbx
0x00000008014a30ce <_thr_rtld_init+238>:    mov    %rbx,%rsp
0x00000008014a30d1 <_thr_rtld_init+241>:    mov    %rbx,%rdi
0x00000008014a30d4 <_thr_rtld_init+244>:    callq  0x8014991cc <getcontext@plt>
0x00000008014a30d9 <_thr_rtld_init+249>:    mov    %rbx,%rdi
0x00000008014a30dc <_thr_rtld_init+252>:    callq  0x80149901c <__fillcontextx2@plt>
0x00000008014a30e1 <_thr_rtld_init+257>:    lea    -0x8(%rbp),%rsp
0x00000008014a30e5 <_thr_rtld_init+261>:    pop    %rbx
0x00000008014a30e6 <_thr_rtld_init+262>:    pop    %rbp
0x00000008014a30e7 <_thr_rtld_init+263>:    retq
End of assembler dump.
Sincerely yours Andre.
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @kostikbel: "<quote>
%rbp-%rsp == 0xf0b4d0 == 15774928
Can you do the following:
1. Compile and run the program at the end of the message and send me
the output.
2. Also send me the first 40 lines of the dmesg for bootverbose boot.
3. (Optional) Install x86info program, compiled from the sources on
github, <url> then run, as root
	kldload cpuctl
	x86info -a
#include <stdio.h>
extern int __getcontextx_size(void);
int main(void)
{
	printf("%#x\n", __getcontextx_size());
}
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @ortadur: "Kudos to Konstantin Belousov!
I'm not sure if this list was interested into all this error tracking.  So we made the error tracking with private mails.
Anyway, it was a BIOS setting named "limit CPUID maximum" and I had to disable it (BIOS help said "disabled for Windows XP").
Thank you Konstantin Belousov, you have an amazing skill in this low level debugging stuff. :)
Sincerely yours Andre.
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @adrianchadd: "hi!
What was that option actually doing? How'd it break things?
-adrian
<quote>
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
    @ortadur: "Hi,
<quote>
old operating systems like Windows 98 can't handle a CPUID higher than 3.  But Pentium 4 with HTT (Hyper-Threading Technologie) has a higher value.  So the BIOS can limit it to 3.
The default value from the BIOS is set to limit the CPUID.  And this caused troubles with FreeBSD which used for all but the first CPU a far bigger data structure (ucontext_t) for threads.  So sometimes the stack didn't had enough space for this big structure and made a segmentation fault (see subject -> many core dumps).
This become fixed by Konstantin Belousov today.  So the next FreeBSD release won't be affected by this BIOS setting on P4 with HTT.
Sincerely yours Andre.
_______________________________________________
<email_address> mailing list
<url>
To unsubscribe, send any mail to "<email_address>""
{'source': 'USENET', 'other_information': '{"reply_count": 14, "forum_name": "muc.lists.freebsd.stable.20150814.mbox"}', 'file': 'data/output/usenet-muc.lists.parquet'}