[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: stack base (was Re: someone could port libgc)

> >
> >    > Doesn't it store it in __libc_stack_end?  See
> >    > libc/sysdeps/generic/libc-start.c .  This program
> >    >
> >    >     extern void* __libc_stack_end;
> >    >     main () { printf ("%p\n", __libc_stack_end); }
> >    >
> >    > prints 0xbffffd1c on Linux/i386 and 0x101abfc on Hurd.
> >

Have done some testing of this, whilst working on libgc.  The address above is
not readable and generates a SIGBUS, (well it does here, have you tried reading
the contents of this pointer)?  I need to work out a 'stack start' for libgc,
but cannot use the above variable.

The package libgc has code to find the stack start, by starting with any stack
address, then reading successive higher/lower (stack direction) addresses until
this generates a either a SIGBUS or SIGSEGV signal.  The signal is generated at
the boundary.

I have also been told that using a fixed address is not safe for the Hurd.

One strange anomoly is that this works fine for C; but when I use it in C++ then
signal handlers are not called
(gdb) run mop.cc
Starting program: /home/cal/openc++2.5.7/src/occ mop.cc
[Switching to thread 1246.3]
[Switching to thread 1246.4]

Program received signal SIGBUS, Bus error.
0x1030fbd in GC_find_limit (p=0x1019a08 "¸\212\001", up=1) at ../os_dep.c:604
604                     GC_noop1((word)(*result));
Current language:  auto; currently c
(gdb) quit

This is at start up, when the program is initialising everything, and before it
gets to main.  Does C++ disable signals?


Reply to: