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

Exception backtrace is missing when code only one line of $0 #12542

Open
zw963 opened this issue Sep 29, 2022 · 4 comments
Open

Exception backtrace is missing when code only one line of $0 #12542

zw963 opened this issue Sep 29, 2022 · 4 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:runtime

Comments

@zw963
Copy link
Contributor

zw963 commented Sep 29, 2022

    A little wired when code only one line.
puts $0
╰─ $ cr run 1.cr
Unhandled exception: Nil assertion failed (NilAssertionError)
  from /home/zw963/Crystal/share/crystal/src/nil.cr:108:5 in 'not_nil!'
  from /home/zw963/Crystal/share/crystal/src/crystal/once.cr:44 in '__crystal_main'
  from /home/zw963/Crystal/share/crystal/src/crystal/main.cr:115:5 in 'main_user_code'
  from /home/zw963/Crystal/share/crystal/src/crystal/main.cr:101:7 in 'main'
  from /home/zw963/Crystal/share/crystal/src/crystal/main.cr:127:3 in 'main'
  from /usr/lib/libc.so.6 in '??'
  from /usr/lib/libc.so.6 in '__libc_start_main'
  from ../sysdeps/x86_64/start.S:117 in '_start'
  from ???

No any clue point out what happen.

Although, add one line before it, will point out the correct line in backtrace.

x = 100
puts $0
 ╰─ $ 130  cr 1.cr 
Unhandled exception: Nil assertion failed (NilAssertionError)
  from /home/zw963/Crystal/share/crystal/src/nil.cr:108:5 in 'not_nil!'
  from 1.cr:2:6 in '__crystal_main'
  from /home/zw963/Crystal/share/crystal/src/crystal/main.cr:115:5 in 'main_user_code'
  from /home/zw963/Crystal/share/crystal/src/crystal/main.cr:101:7 in 'main'
  from /home/zw963/Crystal/share/crystal/src/crystal/main.cr:127:3 in 'main'
  from /usr/lib/libc.so.6 in '??'
  from /usr/lib/libc.so.6 in '__libc_start_main'
  from ../sysdeps/x86_64/start.S:117 in '_start'
  from ???

Originally posted by @zw963 in #4776 (comment)

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:runtime labels Oct 1, 2022
@caspiano
Copy link
Contributor

caspiano commented Oct 11, 2022

@zw963 could you please detail more about your environment and build you're running?
I cannot reproduce this on darwin/musl/glibc builds of crystal 1.6.0

@zw963
Copy link
Contributor Author

zw963 commented Oct 11, 2022

@zw963 could you please detail more about your environment and build you're running? I cannot reproduce this on darwin/musl/glibc builds of crystal 1.6.0

What is your's output?

arch linux is here.

 ╰─ $ \cat 1.cr 
puts $0
 ╰─ $ cr version
Crystal 1.6.0 [41573fadb] (2022-10-06)

LLVM: 14.0.6
Default target: x86_64-pc-linux-gnu

no args when build

 ╰─ $ crystal run 1.cr 
Unhandled exception: Nil assertion failed (NilAssertionError)
  from /home/zw963/Crystal/share/crystal/src/nil.cr:108:5 in 'not_nil!'
  from /home/zw963/Crystal/share/crystal/src/crystal/once.cr:44 in '__crystal_main'
  from /home/zw963/Crystal/share/crystal/src/crystal/main.cr:115:5 in 'main_user_code'
  from /home/zw963/Crystal/share/crystal/src/crystal/main.cr:101:7 in 'main'
  from /home/zw963/Crystal/share/crystal/src/crystal/main.cr:127:3 in 'main'
  from /usr/lib/libc.so.6 in '??'
  from /usr/lib/libc.so.6 in '__libc_start_main'
  from ../sysdeps/x86_64/start.S:117 in '_start'
  from ???

@lbguilherme
Copy link
Contributor

This is odd. I also use Arch Linux and I can't reproduce.

$ echo 'puts $0' > e.cr
$ cat e.cr
puts $0
$ crystal version
Crystal 1.6.0 (2022-10-10)

LLVM: 14.0.6
Default target: x86_64-pc-linux-gnu
$ crystal run e.cr
Unhandled exception: Nil assertion failed (NilAssertionError)
  from /usr/lib/crystal/nil.cr:108:5 in 'not_nil!'
  from e.cr:1:6 in '__crystal_main'
  from /usr/lib/crystal/crystal/main.cr:115:5 in 'main_user_code'
  from /usr/lib/crystal/crystal/main.cr:101:7 in 'main'
  from /usr/lib/crystal/crystal/main.cr:127:3 in 'main'
  from /usr/lib/libc.so.6 in '??'
  from /usr/lib/libc.so.6 in '__libc_start_main'
  from ../sysdeps/x86_64/start.S:117 in '_start'
  from ???

Do you have some non-standard linker?

@zw963
Copy link
Contributor Author

zw963 commented Oct 11, 2022

Wired, this issue only happen on my self-compiled crystal compiler which compiler from my laptop directly use dynamic.

if compile use --static from Alpine, it works.

Could you please try compile with following config?

pacman -S automake \
                 git \
                 libevent \
                 gmp \
                 pcre \
                 openssl \
                 libtool \
                 libxml2 \
                 libyaml \
                 gmp \
                 llvm lld \
                 wasmer wasmtime \
                 libedit

make_arg='interpreter=1 stats=1'
    make clean && make crystal $make_arg
mkdir new_cr
DESTDIR=$PWD/new_cr make install
 ╰─ $ pacman -Q |egrep 'automake|libevent|gmp|pcre|openssl|libtool|libyaml|gmp|llvm|lld|wasm|libedit'
automake 1.16.5-1
gmp 6.2.1-2
lib32-gmp 6.2.1-1
lib32-llvm-libs 14.0.6-2
lib32-openssl 1:1.1.1.q-1
lib32-pcre2 10.40-3
libedit 20210910_3.1-1
libevent 2.1.12-2
libtool 2.4.7-5
libyaml 0.2.5-1
lld 14.0.6-1
llvm 14.0.6-3
llvm-libs 14.0.6-3
openssl 1.1.1.q-1
openssl-1.0 1.0.2.u-1
pcre 8.45-3
pcre2 10.40-3
python-pyopenssl 22.1.0-1
wasmer 2.3.0-2
wasmtime 1.0.1-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:runtime
Projects
None yet
Development

No branches or pull requests

4 participants