Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Jan 2004 14:51:23 +0100
From:      Marc Olzheim <marcolz@stack.nl>
To:        Daniel Eischen <eischen@vigrid.com>
Cc:        hackers@freebsd.org
Subject:   Re: libc_r/uthread/uthread_join.c and uthread_create.c
Message-ID:  <20040112135123.GA41657@stack.nl>
In-Reply-To: <20031231143015.GA59104@stack.nl>
References:  <20031231140533.GA56158@stack.nl> <Pine.GSO.4.10.10312310911360.3264-100000@pcnet5.pcnet.com> <20031231143015.GA59104@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help

--Kj7319i9nmIyA2yE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Wed, Dec 31, 2003 at 03:30:15PM +0100, Marc Olzheim wrote:
> So I noticed. But it seems to me as if the undefers could be removed
> from within the if-else-blocks and collapsed into a single undefer just
> beneath the if-else-blocks, right before the
> _thread_leave_cancellation_point();

Hmm, this is just what OpenBSD did...

Any way: new problem / idea:

uthread_create.c: _pthread_create() doesn't clean ebp, so producing a
backtrace, either with gdb, or with gcc's __builtin_frame_address(),
results in garbage, cq. segmentation faults, when for instance the
spawning thread has already been deleted.

The following patch fixes that for i386. I don't have any other systems
available, so I don't know what to do on other systems, but this works
for us.

Zlo

--Kj7319i9nmIyA2yE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="uthread_ebp.patch"

--- /usr/src/lib/libc_r/uthread/pthread_private.h	Tue Oct 22 16:44:02 2002
+++ /usr/src/lib/libc_r/uthread/pthread_private.h	Mon Jan 12 14:34:32 2004
@@ -84,7 +84,8 @@
 	fdata = (char *) (ucp)->uc_mcontext.mc_fpregs;	\
 	__asm__("frstor %0": :"m"(*fdata));		\
 } while (0)
-#define SET_RETURN_ADDR_JB(jb, ra)	(jb)[0]._jb[0] = (int)(ra)
+#define	SET_RETURN_ADDR_JB(jb, ra)	(jb)[0]._jb[0] = (int)(ra)
+#define	SET_FRAME_PTR_JB(jb, fp)	(jb)[0]._jb[3] = (int)(fp)
 #elif	defined(__alpha__)
 #include <machine/reg.h>
 #define	GET_STACK_JB(jb)	((unsigned long)((jb)[0]._jb[R_SP + 4]))
--- /usr/src/lib/libc_r/uthread/uthread_create.c	Wed Jan  8 06:04:26 2003
+++ /usr/src/lib/libc_r/uthread/uthread_create.c	Mon Jan 12 14:23:56 2004
@@ -195,6 +195,7 @@
 			 * _thread_start().
 			 */
 			SET_RETURN_ADDR_JB(new_thread->ctx.jb, _thread_start);
+			SET_FRAME_PTR_JB(new_thread->ctx.jb, NULL);
 
 			/* The stack starts high and builds down: */
 			SET_STACK_JB(new_thread->ctx.jb,

--Kj7319i9nmIyA2yE--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040112135123.GA41657>