This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: GCC's -fsplit-stack disturbing Mach's vm_allocate
- From: Svante Signell <svante dot signell at gmail dot com>
- To: Samuel Thibault <samuel dot thibault at gnu dot org>
- Cc: Thomas Schwinge <thomas at codesourcery dot com>, Ian Lance Taylor <iant at google dot com>, gcc-patches at gcc dot gnu dot org, bug-hurd at gnu dot org, fotis dot koutoulakis at gmail dot com, Roland McGrath <roland at hack dot frob dot com>
- Date: Wed, 09 Apr 2014 09:05:46 +0200
- Subject: Re: GCC's -fsplit-stack disturbing Mach's vm_allocate
- Authentication-results: sourceware.org; auth=none
- References: <8761x7nkks dot fsf at kepler dot schwinge dot homeip dot net> <20130621231655 dot 24D002C14C at topped-with-meat dot com> <87r4fumx2g dot fsf at kepler dot schwinge dot homeip dot net> <CAKOQZ8wZOf8MBdVKiyDcggFBs3A48+QckAoB7XJm+b+E3rkAxQ at mail dot gmail dot com> <87ip10o90k dot fsf at kepler dot schwinge dot homeip dot net> <20140404191416 dot GG5350 at type>
- Reply-to: svante dot signell at gmail dot com
On Fri, 2014-04-04 at 21:14 +0200, Samuel Thibault wrote:
> Hello,
>
> Thomas Schwinge, le Wed 26 Jun 2013 23:30:03 +0200, a écrit :
> > On Sat, 22 Jun 2013 08:15:46 -0700, Ian Lance Taylor <iant@google.com> wrote:
> > > Go can work without split stack. In that case libgo will use much
> > > larger stacks for goroutines, to reduce the chance of running out of
> > > stack space (see StackMin in libgo/runtime/proc.c). So the number of
> > > simultaneous goroutines that can be run will be limited. This is
> > > usually OK on x86_64 but it does hamper Go programs running on 32-bit
> > > x86.
> >
> > OK, but that's not the most pressing issue we're having right now.
> > Anyway, as it stands, the split-stack code doesn't work on Hurd, so I
> > disabled it in r200434 as follows:
>
> Maybe you'd want to re-enable it, now that we have got rid of threadvars :)
I don't think it is a good idea. I've patched gcc-4.9-20140406 to make
gccgo build and tested with -fsplit-stack enabled (with and without the
gold linker). Without split stack around 70 libgo tests pass and 50
fails. With it enabled all tests fail. Simple examples are the following
C code (from Thomas) and GO code:
1)
cat test_split_stack.c
#include <mach.h>
#include <stdio.h>
int main(void)
{
int err;
vm_address_t addr = 0;
int i;
for (i = 0; i < 3; ++i)
{
err = vm_allocate(mach_task_self(), &addr, 4096, 1);
printf("%u %p\n", err, (void *) addr);
}
return 0;
}
$ gcc-4.9 test_split_stack.c -fsplit-stack
$ ./a.out
0 (nil)
0 0x102c000
0 0x1027800
$ gcc-4.9 test_split_stack.c
$ ./a.out
0 0x102c000
0 0x125b000
0 0x125c000
2)
cat hello.go:
package main
import "fmt"
func main() {
fmt.Printf("Hello, world.\n")
}
gccgo-4.9 -g hello.go
./a.out
Hello, world.
LD_PRELOAD=../gcc-4.9-4.9-20140406/build/i486-gnu/libgo/.libs/libgo.so.5.0.0 ./a.out
mmap errno 1073741846
fatal error: mmap
runtime stack:
^C
Something is still not OK with the treads library?
Patches for gccgo on GNU/Hurd will be submitted to the Debian BTS.