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

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

Conversation

ysbaddaden
Copy link
Contributor

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
src/thread.cr Outdated Show resolved Hide resolved
src/thread.cr Outdated Show resolved Hide resolved
@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
Contributor 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
4 participants