public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug nptl/17165] New: [alpha] Saved stack pointer is not mangled in unwind_stop jumpbuffer
Date: Wed, 16 Jul 2014 16:17:00 -0000 [thread overview]
Message-ID: <bug-17165-131@http.sourceware.org/bugzilla/> (raw)
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.
>From glibc-bugs-return-25838-listarch-glibc-bugs=sources.redhat.com@sourceware.org Wed Jul 16 16:18:00 2014
Return-Path: <glibc-bugs-return-25838-listarch-glibc-bugs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-glibc-bugs@sources.redhat.com
Received: (qmail 10134 invoked by alias); 16 Jul 2014 16:18:00 -0000
Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <glibc-bugs.sourceware.org>
List-Subscribe: <mailto:glibc-bugs-subscribe@sourceware.org>
List-Post: <mailto:glibc-bugs@sourceware.org>
List-Help: <mailto:glibc-bugs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: glibc-bugs-owner@sourceware.org
Delivered-To: mailing list glibc-bugs@sourceware.org
Received: (qmail 10060 invoked by uid 48); 16 Jul 2014 16:17:56 -0000
From: "ubizjak at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug nptl/17165] [alpha] Saved stack pointer is not mangled in unwind_stop jumpbuffer
Date: Wed, 16 Jul 2014 16:18:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: glibc
X-Bugzilla-Component: nptl
X-Bugzilla-Version: 2.17
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ubizjak at gmail dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at sourceware dot org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cf_gcctarget
Message-ID: <bug-17165-131-hLkxWylFbA@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-17165-131@http.sourceware.org/bugzilla/>
References: <bug-17165-131@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-07/txt/msg00621.txt.bz2
Content-length: 380
https://sourceware.org/bugzilla/show_bug.cgi?id\x17165
Uros Bizjak <ubizjak at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |alpha-linux-gnu
--
You are receiving this mail because:
You are on the CC list for the bug.
next reply other threads:[~2014-07-16 16:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-16 16:17 ubizjak at gmail dot com [this message]
2014-07-16 16:39 ` [Bug nptl/17165] " ubizjak at gmail dot com
2014-07-16 17:16 ` ubizjak at gmail dot com
2014-07-30 5:21 ` rth at gcc dot gnu.org
2014-07-30 6:36 ` ubizjak at gmail dot com
2014-07-30 7:48 ` ubizjak at gmail dot com
2014-07-30 17:17 ` rth at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-17165-131@http.sourceware.org/bugzilla/ \
--to=sourceware-bugzilla@sourceware.org \
--cc=glibc-bugs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).