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

Compiler segfault in alpine but not centos8 #11041

Closed
will opened this issue Jul 30, 2021 · 4 comments
Closed

Compiler segfault in alpine but not centos8 #11041

will opened this issue Jul 30, 2021 · 4 comments
Labels

Comments

@will
Copy link
Contributor

will commented Jul 30, 2021

On centos8, everything works alright:

[centos@ip-172-28-240-100 cb]$ uname -a
Linux ip-172-28-240-100.us-west-2.compute.internal 4.18.0-305.3.1.el8.x86_64 #1 SMP Tue Jun 1 16:14:33 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[centos@ip-172-28-240-100 cb]$ crystal --version
Crystal 1.1.1 [6d9a1d583] (2021-07-26)

LLVM: 10.0.1
Default target: x86_64-unknown-linux-gnu
[centos@ip-172-28-240-100 cb]$ shards build -s
Dependencies are satisfied
Building: cb
Parse:                             00:00:00.002276749 (   1.00MB)
Semantic (top level):              00:00:00.573018851 (  74.32MB)
Semantic (new):                    00:00:00.002739744 (  74.32MB)
Semantic (type declarations):      00:00:00.100629685 (  74.32MB)
Semantic (abstract def check):     00:00:00.009171972 (  74.32MB)
Semantic (ivars initializers):     00:00:00.021925261 (  90.32MB)
Semantic (cvars initializers):     00:00:00.068884934 ( 106.32MB)
Semantic (main):                   00:00:01.934609761 ( 250.75MB)
Semantic (cleanup):                00:00:00.006690541 ( 250.75MB)
Semantic (recursive struct check): 00:00:00.001527295 ( 250.75MB)
Codegen (crystal):                 00:00:02.820418446 ( 299.25MB)
Codegen (bc+obj):                  00:00:01.468691736 ( 299.25MB)
Codegen (linking):                 00:00:00.642008240 ( 299.25MB)

Codegen (bc+obj):
 - 887/888 .o files were reused

These modules were not reused:
 - _main (_main.bc)

However with an alpine docker image

[centos@ip-172-28-240-100 cb]$  sudo docker run --rm -v `pwd`:/workspace -w /workspace -it cb-static-builder-amd64:latest /bin/sh
/workspace # uname -a
Linux e7b0856376dc 4.18.0-305.3.1.el8.x86_64 #1 SMP Tue Jun 1 16:14:33 UTC 2021 x86_64 Linux
[centos@ip-172-28-240-100 cb]$ crystal --version
Crystal 1.1.1 [6d9a1d583] (2021-07-26)

LLVM: 10.0.1
Default target: x86_64-unknown-linux-gnu
/workspace # shards build -s
Dependencies are satisfied
Building: cb
Parse:                             00:00:00.001736556 (   0.79MB)
Error target cb failed to compile:
Invalid memory access (signal 11) at address 0x564e649d3838
[0x564da48c8186] ???
[0x564da48c8153] ???
[0x7fa76a516304] ???

The docker file is at https://github.com/will/cb/blob/main/Dockerfile

@will will added the kind:bug label Jul 30, 2021
@will will changed the title Compiler segfault in alpine but not lentos Compiler segfault in alpine but not centos8 Jul 30, 2021
@will
Copy link
Contributor Author

will commented Jul 30, 2021

I couldn't get much out of lldb. I'm not very good at lldb.

[centos@ip-172-28-240-100 cb]$  sudo docker run --privileged --cap-add=SYS_PTRACE --security-opt seccomp=unconfined  --rm -v `pwd`:/workspace -w /workspace -it cb-static-builder-amd64:latest /bin/sh
/workspace # apk add lldb
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/3) Installing llvm10-libs (10.0.0-r2)
(2/3) Installing libedit (20191231.3.1-r0)
(3/3) Installing lldb (10.0.0-r0)
Executing busybox-1.31.1-r16.trigger
OK: 556 MiB in 84 packages
/workspace # lldb shards -- build
(lldb) target create "shards"
Current executable set to 'shards' (x86_64).
(lldb) settings set -- target.run-args  "build"
(lldb) run
Process 16 launched: '/usr/bin/shards' (x86_64)
Process 16 stopped
* thread #1, name = 'shards', stop reason = signal SIGSEGV: invalid address (fault address: 0x55555584df00)
    frame #0: 0x00007ffff7e95463
->  0x7ffff7e95463: movsbq (%rax), %rdi
    0x7ffff7e95467: callq  0x7ffff7e88300
    0x7ffff7e9546c: jmp    0x7ffff7e953f4
    0x7ffff7e9546e: callq  0x7ffff7e87ed0
(lldb) bt
* thread #1, name = 'shards', stop reason = signal SIGSEGV: invalid address (fault address: 0x55555584df00)
  * frame #0: 0x00007ffff7e95463
(lldb) l
(lldb) 

@straight-shoota
Copy link
Member

We're experiencing several issues with segfaults on alpine. The test_alpine CI job is constantly failing, for example. This shouldn't happen on alpine 3.12, though (#10366).

Looks like you're using the 1.1.0 compiler from alpine edge. That build is broken: https://gitlab.alpinelinux.org/alpine/aports/-/issues/12854

@will
Copy link
Contributor Author

will commented Jul 30, 2021

Looks like you're using the 1.1.0 compiler from alpine edge

I think it's 1.1.1 but still from the --version output, but still broken. But thanks for pointing out the source of the problem.

I've gone back to 1.0.0 for just the linux builds with RUN apk add --update --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/latest-stable/community crystal shards instead, and that fixed it.

@maxfierke the dockerfile I was using was from your mtrap project, so you might also run into this, just fyi.

@straight-shoota I'd close this issue now unless you think there is some value in tracking the issue here too. If not feel free to close it.

edit: I made an account on their gitlab instance, but it won't let me subscribe for notifications :( I put in an email address.

@beta-ziliani
Copy link
Member

Thanks @will, I'm closing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants