Crystal: OverflowError always lead to can't raise END_OF_STACK

Created on 4 Feb 2019  路  3Comments  路  Source: crystal-lang/crystal

Happens systematically on Ubuntu 14.04 / x86_64-linux-gnu for me.

It seems Debug::ELF and/or Debug::DWARF are trying to raise an exception but fail to 鈥攂ecause we're already inside an exception handler?

Yet, compiling with --no-debug has no impact (it still raises an OverflowError).

bug

Most helpful comment

I found the culprit for the weird make behavior:
https://github.com/crystal-lang/crystal/blob/master/src/fiber.cr#L106-L108

$ ./hello
stack_size = rlim.rlim_cur # => 8388608_u64
@stack_bottom.address # => 140726095376384_u64

$ make
rlim.rlim_cur # => 18446744073709551615_u64
@stack_bottom.address # => 140737488347136_u64

We thus can't use the soft limit of RLIMIT_STACK to detect the stack bottom top of the main thread/fiber stack, and should use other means (non portable pthread calls).

All 3 comments

Trying to debug this, I noticed a very weird behavior: the build program will crash with an OverflowError when run from make, but will succeed when called outside of make:

# hello.cr
puts "hello"

```Makefile
.POSIX:

all: .phony
bin/crystal build -Dpreview_overflow hello.cr
./hello

.phony:


Direct call: :heavy_check_mark: 
```console
$ bin/crystal run -Dpreview_overflow hello.cr
Using compiled compiler at `.build/crystal'
hello

Indirect call through GNU make: :x:

$ make
bin/crystal build -Dpreview_overflow hello.cr
Using compiled compiler at `.build/crystal'
./hello
Unhandled exception: Overflow (OverflowError)
Failed to raise an exception: END_OF_STACK

Direct call of built binary (that crashed through make): :heavy_check_mark:

$ ./hello
hello

Notice that the program doesn't even reach puts, and is failing somewhere in the prelude.

I found the culprit for the weird make behavior:
https://github.com/crystal-lang/crystal/blob/master/src/fiber.cr#L106-L108

$ ./hello
stack_size = rlim.rlim_cur # => 8388608_u64
@stack_bottom.address # => 140726095376384_u64

$ make
rlim.rlim_cur # => 18446744073709551615_u64
@stack_bottom.address # => 140737488347136_u64

We thus can't use the soft limit of RLIMIT_STACK to detect the stack bottom top of the main thread/fiber stack, and should use other means (non portable pthread calls).

This is a duplicate a #7368.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ArthurZ picture ArthurZ  路  3Comments

lgphp picture lgphp  路  3Comments

TechMagister picture TechMagister  路  3Comments

nabeelomer picture nabeelomer  路  3Comments

will picture will  路  3Comments