This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nptl/17165] New: [alpha] Saved stack pointer is not mangled in unwind_stop jumpbuffer
- From: "ubizjak at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Wed, 16 Jul 2014 16:17:15 +0000
- Subject: [Bug nptl/17165] New: [alpha] Saved stack pointer is not mangled in unwind_stop jumpbuffer
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=17165
Bug ID: 17165
Summary: [alpha] Saved stack pointer is not mangled in
unwind_stop jumpbuffer
Product: glibc
Version: 2.17
Status: NEW
Severity: normal
Priority: P2
Component: nptl
Assignee: unassigned at sourceware dot org
Reporter: ubizjak at gmail dot com
CC: drepper.fsp at gmail dot com
Following testcase:
--cut here--
#include <bits/cxxabi_forced.h>
#include <pthread.h>
void* f(void*) {
try
{
pthread_exit(0);
}
catch (__cxxabiv1::__forced_unwind const&)
{
__builtin_puts("unwind");
throw;
}
catch (...)
{
__builtin_puts("something else");
throw;
}
}
int main()
{
pthread_t t;
pthread_create(&t, 0, f, 0);
pthread_join(t, 0);
}
--cut here--
executes on alpha-linux-gnu without printing anything when compiled with
"gcc-4.9 -pthread". The problem was tracked to invalid execution of unwind_stop
from nptl/unwind.c.
The referred function calls _jmpbuf_sp:
0033 static inline uintptr_t __attribute__ ((unused))
0034 _jmpbuf_sp (__jmp_buf regs)
0035 {
0036 uintptr_t sp = regs[JB_SP];
0037 #ifdef PTR_DEMANGLE
0038 PTR_DEMANGLE (sp);
0039 #endif
0040 return sp;
through _JMPBUF_CFA_UNWINDS_ADJ/ _JMPBUF_UNWINDS_ADJ macros, defined in
âsysdeps/âalpha/âjmpbuf-unwind.h. However, regs[JB_SP] is not mangled at all at
function entry, as confirmed by following gdb session:
(gdb) b jmpbuf-unwind.h:38
No source file named jmpbuf-unwind.h.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (jmpbuf-unwind.h:38) pending.
(gdb) r
Starting program: /space/homedirs/uros/test/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
[New Thread 0x20000c391f0 (LWP 11609)]
[Switching to Thread 0x20000c391f0 (LWP 11609)]
Breakpoint 1, unwind_stop (version=<optimized out>, actions=<optimized out>,
exc_class=<optimized out>, exc_obj=<optimized out>, context=<optimized out>,
stop_parameter=<optimized out>) at unwind.c:61
61 || ! _JMPBUF_CFA_UNWINDS_ADJ (buf->cancel_jmp_buf[0].jmp_buf,
context,
(gdb) s
_jmpbuf_sp (regs=0x20000c38a40) at ../ports/sysdeps/alpha/jmpbuf-unwind.h:38
38 PTR_DEMANGLE (sp);
(gdb) p/x regs[8]
$1 = 0x20000c38a10
Following detail can be obtained from dissasembly:
0x000002000028774c <+188>: ldq s1,64(a5) <-- load SP value
0x0000020000287750 <+192>: ldq t0,0(t0) <-- load ptr chk guard
=> 0x0000020000287754 <+196>: xor s1,t0,s1 <-- mangling function
just before mangling function, we have:
(gdb) i r s1 t0
s1 0x20000c38a10 2199036070416
t0 0x33608b9cba2ff160 3702112398953410912
The consequence of the wrong value is, that do_longjump flag gets set in
unwind_stop function. This caused errorneous call to __libc_unwind_longjmp at
the end of the function, which silently terminates the execution.
I suspect a missing call to PTR_MANGLE, or one of PTR_MANGLE* macros in
sysdeps/unix/alpha/sysdep.h is not defined correctly, so saved SP value in
jmp_buf isn't mangled as expected by unwind_stop function.
--
You are receiving this mail because:
You are on the CC list for the bug.