Pierre Palatin wrote:
> On Monday 19 March 2007 21:13:12 Thiemo Seufer wrote:
> > J. Mayer wrote:
> > > On Mon, 2007-03-19 at 12:16 +0000, Thiemo Seufer wrote:
> > > > CVSROOT:        /sources/qemu
> > > > Module name:    qemu
> > > > Changes by:     Thiemo Seufer <ths>     07/03/19 12:16:29
> > > >
> > > > Modified files:
> > > >         linux-user     : main.c
> > > >
> > > > Log message:
> > > >         Support -cpu selection for mips usermode emulation. Fix 
> > > > segfault when
> > > >         dispaying the -cpu list help.
> > >
> > > Could you tell more about the segfault ?
> >
> > It segfaulted for me (on ppc/linux) after printing the help list.
> >
> > > exit is used at many other places without any problem and furthermore I
> > > did not experiment any crash while testing the PowerPC target with the
> > > initial patch, so ? (I'd really like to understand...)
> >
> > I didn't really debug it, but I noticed the other branch in the
> > conditional uses _exit() instead of exit(). With that change, the
> > segfault disappeared. I figure we have an atexit/on_exit call somwhere
> > which tries to use data which isn't initialized at that point.
> 
> Maybe that's related to the problem i've got (in 
> http://lists.gnu.org/archive/html/qemu-devel/2007-03/msg00110.html ).
>
> There is some piece of code in main.c which mess around libc initialization & 
> exit and were making my qemu-i386 segfault really early. It seems it was 
> designed to avoid a bug in some versions of glibc.
> I attach the simple patch I've made to avoid that. 
> It may need adjustements since I don't know enough about libc internals on 
> initialization to be sure that's the correct fix - I would be deeply 
> interested in some input/comments on this problem.
> 
> Pierre Palatin

> Index: linux-user/main.c
> ===================================================================
> --- linux-user/main.c (révision 527)
> +++ linux-user/main.c (copie de travail)
> @@ -44,7 +44,7 @@
>  
>  /* for recent libc, we add these dummy symbols which are not declared
>     when generating a linked object (bug in ld ?) */
> -#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && 
> !defined(CONFIG_STATIC)
> +#if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 3) && !defined(CONFIG_STATIC)
>  long __preinit_array_start[0];
>  long __preinit_array_end[0];
>  long __init_array_start[0];

binutils' ld had a bug a while ago, this looks like a workaround for it
(which means the check for glibc is wrong, and there's no easy way to
do it right).

Commenting out that code made no difference to me.


Thiemo


_______________________________________________
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Reply via email to