Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gccgo: Go compiled with gcc 8.3 does not start on powerpc-linux-musl #30538

Open
awilfox opened this issue Mar 3, 2019 · 6 comments
Open

gccgo: Go compiled with gcc 8.3 does not start on powerpc-linux-musl #30538

awilfox opened this issue Mar 3, 2019 · 6 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@awilfox
Copy link

awilfox commented Mar 3, 2019

What version of Go are you using (go version)?

$ go version
fatal error: runtime: cannot reserve arena virtual address space
runtime: panic before malloc heap initialized`

Does this issue reproduce with the latest release?

Yes, this is 8.3.0:

gcc (Adelie 8.3.0) 8.3.0

What operating system and processor architecture are you using (go env)?

Adélie Linux 1.0-BETA3, on 32-bit PowerPC (musl libc, big endian)

What did you do?

Built GCC 8.3 with --enable-languages=c,c++,fortran,go.

What did you expect to see?

A working Go runtime.

What did you see instead?

awilcox on gwyn [pts/3 Sun 3 2:32] ~: go version
fatal error: runtime: cannot reserve arena virtual address space
runtime: panic before malloc heap initialized

runtime stack:

        :0
runtime.throw
        :0
runtime.schedinit
        :0

        :0
libc_start_main_stage2
        src/env/__libc_start_main.c:94

Notes

GCC 6.4 does not crash with that error, instead crashing further in:

fatal error: unexpected signal during runtime execution
[signal 0xb code=0x2 addr=0x20000426]

goroutine 16 [running]:

        :0

        :0

        :0

        :0

        :0

        :0

        :0

        :0

        :0
__go_init_main
        /home/awilcox/hello.go:1

        :0

        :0

        :0
created by main
        /usr/src/packages/system/gcc/src/gcc-6.4.0/libgo/runtime/go-main.c:54
@awilfox
Copy link
Author

awilfox commented Mar 3, 2019

Output of strace go version:

execve("/usr/bin/go", ["go", "version"], 0xffd3acd4 /* 46 vars */) = 0
set_tid_address(0xf79ad100)             = 23732
open("/etc/ld-musl-powerpc.path", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib/libgo.so.13", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libgo.so.13", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/libgo.so.13", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
fstat64(3, {st_mode=S_IFREG|0755, st_size=20273140, ...}) = 0
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0e\347\320\0\0\0004"..., 936) = 936
mmap2(NULL, 18178048, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xf6775000
mmap2(0xf75fd000, 2940928, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xe78000) = 0xf75fd000
mmap2(0xf78ad000, 122880, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xf78ad000
close(3)                                = 0
open("/lib/libz.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
fstat64(3, {st_mode=S_IFREG|0755, st_size=132508, ...}) = 0
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\0\34`\0\0\0004"..., 936) = 936
mmap2(NULL, 200704, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xf6744000
mmap2(0xf6773000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x1f000) = 0xf6773000
close(3)                                = 0
open("/lib/libucontext.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
fstat64(3, {st_mode=S_IFREG|0755, st_size=66644, ...}) = 0
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\0\5\20\0\0\0004"..., 936) = 936
mmap2(NULL, 135168, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xf6723000
mmap2(0xf6742000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xf000) = 0xf6742000
close(3)                                = 0
open("/lib/libgcc_s.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libgcc_s.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/libgcc_s.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=132336, ...}) = 0
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\0\"\320\0\0\0004"..., 936) = 936
mmap2(NULL, 200704, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xf66f2000
mmap2(0xf6721000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x1f000) = 0xf6721000
close(3)                                = 0
mprotect(0xf75fd000, 1736704, PROT_READ) = 0
mprotect(0xf6773000, 4096, PROT_READ)   = 0
mprotect(0xf6742000, 4096, PROT_READ)   = 0
mprotect(0xf6721000, 4096, PROT_READ)   = 0
mprotect(0xa69000, 77824, PROT_READ)    = 0
sched_getaffinity(0, 128, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]) = 32
brk(NULL)                               = 0x10f8000
write(2, "fatal error: ", 13fatal error: )           = 13

Interestingly, it doesn't seem to be calling mmap from sysReserve. Setting a breakpoint on mmap in gdb yielded this interesting trace:

(gdb) bt
#0  __mmap (start=0x600000, len=807411712, prot=0, flags=34, fd=-1, off=27021597898440704) at src/mman/mmap.c:15
#1  0xf785c2b8 in ?? () from /usr/lib/libgo.so.13
#2  0xf785c500 in ?? () from /usr/lib/libgo.so.13
#3  0xf7898414 in runtime.schedinit () from /usr/lib/libgo.so.13
#4  0x00439a44 in ?? ()
#5  0xf7f4004c in libc_start_main_stage2 (main=0x439970, argc=2, argv=0xffffe2e4) at src/env/__libc_start_main.c:94
#6  0xf7f400b8 in __libc_start_main (main=0x439970, argc=2, argv=<optimized out>) at src/env/__libc_start_main.c:85
#7  0x00439adc in ?? ()
#8  0x00439a94 in ?? ()

That value of off is causing musl to set EINVAL. Similar calls for each attempted arena size are seen:

Breakpoint 1, __mmap (start=0x600000, len=538976256, prot=0, flags=34, fd=-1, off=27021597898440704) at src/mman/mmap.c:15
15      in src/mman/mmap.c
(gdb) c
Continuing.

Breakpoint 1, __mmap (start=0x600000, len=404758528, prot=0, flags=34, fd=-1, off=27021597898440704) at src/mman/mmap.c:15
15      in src/mman/mmap.c
(gdb) c
Continuing.

Breakpoint 1, __mmap (start=0x600000, len=270540800, prot=0, flags=34, fd=-1, off=27021597898440704) at src/mman/mmap.c:15
15      in src/mman/mmap.c
(gdb) c

@awilfox
Copy link
Author

awilfox commented Mar 3, 2019

Changing the definition of sysMmap in go/runtime/mem_gccgo.go to take the correct argument type for musl, a 64-bit signed integer (as off_t is always 64-bit on musl), fixes this crash.

@odeke-em odeke-em changed the title [8 Regression] GCC Go 8.3 does not start on powerpc-linux-musl gccgo: GCC Go 8.3 does not start on powerpc-linux-musl Mar 3, 2019
@gopherbot gopherbot added this to the Gccgo milestone Mar 3, 2019
@odeke-em odeke-em changed the title gccgo: GCC Go 8.3 does not start on powerpc-linux-musl gccgo: Go compiled with gcc 8.3 does not start on powerpc-linux-musl Mar 3, 2019
@odeke-em
Copy link
Member

odeke-em commented Mar 3, 2019

Thank you for reporting this issue @awilfox!

Kindly paging @ianlancetaylor @aclements @laboger

@ianlancetaylor
Copy link
Contributor

@awilfox Can you please paste the output of grep off_t */libgo/runtime_sysinfo.go, looking at the generated file runtime_sysinfo.go in the libgo build directory. Thanks.

@awilfox
Copy link
Author

awilfox commented Mar 9, 2019

It's consistent on every platform. The output matches on our ppc64 and armv7 builders:

awilcox on erin [pts/1 Fri 8 23:22] libgo: grep off_t runtime_sysinfo.go
type _off_t int64

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 12, 2019
@gopherbot
Copy link

Change https://golang.org/cl/170863 mentions this issue: cmd/gopherbot: CC triaged issues to owners

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants