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

Crystal 0.27.1 built with --release crashes immediately with OverflowError #7368

Closed
ysbaddaden opened this issue Feb 4, 2019 · 6 comments · Fixed by #7373
Closed

Crystal 0.27.1 built with --release crashes immediately with OverflowError #7368

ysbaddaden opened this issue Feb 4, 2019 · 6 comments · Fixed by #7373
Assignees
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc.

Comments

@ysbaddaden
Copy link
Contributor

ysbaddaden commented Feb 4, 2019

If I compile 0.27.1 (or master) with --release -Dpreview_overflow, then I can't compile anything anymore, not even Crystal itself. The compiler crashes immediately:

$ make -B
CRYSTAL_CONFIG_BUILD_COMMIT="0ef090a" ./bin/crystal build -D preview_overflow -D compiler_rt --release  -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib
Using compiled compiler at `.build/crystal'
Unhandled exception: Overflow (OverflowError)
Failed to raise an exception: END_OF_STACK
[0xd30ca6] ???
[0x417cfb] __crystal_raise +43
[0x429963] ???
[0x422979] ???
[0x41f388] ???
[0x4522bd] ???
[0x41bdbd] main +45
[0x2acaf91c0f45] __libc_start_main +245
[0x41416f] ???
[0x0] ???
make: *** [.build/crystal] Erreur 5

Note that I can build a working compiler with -Dpreview_overflow only (without --release).

All my Travis jobs are currently broken, since the Linux packages of 0.27.1 have been built with these options.

OS: Ubuntu 14.04
Target: x86_64-linux-gnu

@ysbaddaden ysbaddaden added the kind:bug A bug in the code. Does not apply to documentation, specs, etc. label Feb 4, 2019
@ysbaddaden
Copy link
Contributor Author

When I say "immediately" I mean it: if I pass --stats then I don't get anything printed.

@ysbaddaden ysbaddaden assigned ysbaddaden and unassigned bcardiff Feb 4, 2019
ysbaddaden added a commit to ysbaddaden/crystal that referenced this issue Feb 4, 2019
Using `getrlimit` led to invalid STACK SIZE limits in some cases
which in turn led to an integer overflow while detecting the stack
base of the main stack.

This patch replaces `getrlimit` with proper, but non portable, calls
to pthread functions that return the stack of a given thread.

fixes crystal-lang#7368
fixes crystal-lang#7369
ysbaddaden added a commit to ysbaddaden/crystal that referenced this issue Feb 4, 2019
Using `getrlimit` led to invalid STACK SIZE limits in some cases
which in turn led to an integer overflow while detecting the stack
base of the main stack.

This patch replaces `getrlimit` with proper, but non portable, calls
to pthread functions that return the stack of a given thread.

fixes crystal-lang#7368
fixes crystal-lang#7369
ysbaddaden added a commit to ysbaddaden/crystal that referenced this issue Feb 4, 2019
Using `getrlimit` led to invalid STACK SIZE limits in some cases
which in turn led to an integer overflow while detecting the stack
base of the main stack.

This patch replaces `getrlimit` with proper, but non portable, calls
to pthread functions that return the stack of a given thread.

fixes crystal-lang#7368
fixes crystal-lang#7369
@oprypin
Copy link
Member

oprypin commented Feb 4, 2019

Here are cases of (what I think is) this problem caught in CI:
https://travis-ci.org/oprypin/crsfml/jobs/488077739
https://travis-ci.org/myst-lang/myst/jobs/487864236
https://travis-ci.org/anykeyh/clear/jobs/488396058
Ideally we'd catch such things before release

@ysbaddaden
Copy link
Contributor Author

@oprypin this should be fixed by #7373.

@ysbaddaden
Copy link
Contributor Author

This is an unfortunate course of events. An unexpected bogus value with RLIMIT_STACK on Linux when run inside make led to an integer overflow in Fiber.new (main thread's main fiber). In addition, the Crystal Makefile already turns on the integer overflow checks.

Weirdly, it affects a simple hello world program, but doesn't affect the compiler built in non-release mode. It only affects the compiler when built with make release=1, which cause the compiler to crash immediately, also leading to the END_OF_STACK —maybe because the crystal runtime isn't fully initialized.

That could have been found out sooner, but compiling crystal in release mode takes a long time, so I usually only use a manually built compiler in non-release mode —I guess nightly does the same?

@bcardiff
Copy link
Member

bcardiff commented Feb 4, 2019

@oprypin catching before release today is only available as docker images which none of those projects use unfortunately.

As @ysbaddaden pointed, checks in nightly can be be improved. The compiler used during the specs is not built in release mode, and the distributable which is compiled in release mode is not actually used.

@bcardiff
Copy link
Member

bcardiff commented Feb 4, 2019

Using the compiled packages to run specs would have caught #7289 also.

bcardiff pushed a commit that referenced this issue Feb 4, 2019
Using `getrlimit` led to invalid STACK SIZE limits in some cases
which in turn led to an integer overflow while detecting the stack
base of the main stack.

This patch replaces `getrlimit` with proper, but non portable, calls
to pthread functions that return the stack of a given thread.

fixes #7368
fixes #7369
bcardiff pushed a commit that referenced this issue Feb 4, 2019
Using `getrlimit` led to invalid STACK SIZE limits in some cases
which in turn led to an integer overflow while detecting the stack
base of the main stack.

This patch replaces `getrlimit` with proper, but non portable, calls
to pthread functions that return the stack of a given thread.

fixes #7368
fixes #7369
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants