Skip to content

Fix: integer overflow in main thread stack base detection#7373

Merged
bcardiff merged 1 commit intocrystal-lang:masterfrom
ysbaddaden:fix/overflow-error-in-main-fiber-stack-base-detection
Feb 4, 2019
Merged

Fix: integer overflow in main thread stack base detection#7373
bcardiff merged 1 commit intocrystal-lang:masterfrom
ysbaddaden:fix/overflow-error-in-main-fiber-stack-base-detection

Conversation

@ysbaddaden
Copy link
Collaborator

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.

Note: only tested on x86_64-linux-gnu. I didn't test on macOS, FreeBSD or OpenBSD.

fixes #7368
fixes #7369

@ysbaddaden ysbaddaden added the kind:bug A bug in the code. Does not apply to documentation, specs, etc. label Feb 4, 2019
@bcardiff bcardiff added this to the 0.27.2 milestone 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 ysbaddaden force-pushed the fix/overflow-error-in-main-fiber-stack-base-detection branch from 0da2b62 to e394c64 Compare February 4, 2019 17:37
@ysbaddaden
Copy link
Collaborator Author

CI should pass now 🤞

@bcardiff
Copy link
Member

bcardiff commented Feb 4, 2019

Manually checked in macOS & FreeBSD. :shipit:

@bcardiff bcardiff merged commit 17c64da into crystal-lang:master Feb 4, 2019
@bcardiff
Copy link
Member

bcardiff commented Feb 4, 2019

Thanks @ysbaddaden 💯 👑

@oprypin
Copy link
Member

oprypin commented Feb 4, 2019

Presumably this will require a new release?

@bcardiff
Copy link
Member

bcardiff commented Feb 4, 2019

Yes @oprypin we will release 0.27.2 tomorrow probably with the fixed indicated in that milestone.

@ysbaddaden ysbaddaden deleted the fix/overflow-error-in-main-fiber-stack-base-detection branch February 4, 2019 22:09
bcardiff pushed a commit that referenced this pull request 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. topic:stdlib:runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OverflowError always lead to can't raise END_OF_STACK Crystal 0.27.1 built with --release crashes immediately with OverflowError

4 participants