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

Thread.allocate_stack: Pass MAP_STACK to mmap() on OpenBSD 6.3+ #6250

Merged
merged 1 commit into from Jun 27, 2018

Conversation

Projects
None yet
3 participants
@jcs
Contributor

jcs commented Jun 23, 2018

This is required as of OpenBSD 6.3.

@bcardiff

This comment has been minimized.

Member

bcardiff commented Jun 23, 2018

Thanks, is there any reference for this at least to add in the PR?

Is there any program you tried and is failing on openbsd without this patch?

@jcs

This comment has been minimized.

Contributor

jcs commented Jun 23, 2018

The compiler will crash when compiling:

./bin/crystal build  -o .build/std_spec spec/std_spec.cr
Using compiled compiler at `.build/crystal'
Invalid memory access (signal 11) at address 0x0
[0xbff7b532456] *CallStack::print_backtrace:Int32 +118
[0xbff7b514f5b] __crystal_sigfault_handler +75
[0xbff7c206a30] sigfault_handler +48
gmake: *** [Makefile:112: .build/std_spec] Error 11

And a kernel message logged:

trap [crystal]753/414181 type 262: sp 187f8632fbe0 not inside 7f7fffbf6000-7f7fffff5000

This is due to a change in OpenBSD 6.3 which required similar changes in Go and other language ports.

@ysbaddaden

This comment has been minimized.

Member

ysbaddaden commented Jun 24, 2018

Does STACK_MAP exists in previous, still supported, openbsd releases? Such as 6.2?

@jcs

This comment has been minimized.

Contributor

jcs commented Jun 26, 2018

Oops, it will be required for OpenBSD 6.4 (and 6.3-current now). The flag was added for 6.3 but was ignored under the hood, but using the flag in previous versions will return an error. Is there a proper way to check a system .h header when compiling to toggle a flag?

I am getting other crashes when trying to compile the compiler or when running 'make spec', which I am looking into.

@ysbaddaden

This comment has been minimized.

Member

ysbaddaden commented Jun 26, 2018

I believe the target triple is amd64-unknown-openbsd6.X, right? If so, You can try:

{% if flag?(:openbsd) && !flag?(:"openbsd6.2") %}
@jcs

This comment has been minimized.

Contributor

jcs commented Jun 27, 2018

I've updated the commit to skip openbsd6.2.

@jcs

This comment has been minimized.

Contributor

jcs commented Jun 27, 2018

I've also run crystal tool format on mman.cr since the CI tests appear to require this to pass.

jcs added a commit to jcs/crystal-openbsd-port that referenced this pull request Jun 27, 2018

Update to 0.25.0, shards to 0.8.1
- Add MAP_STACK patches which are pending upstream commit
  (crystal-lang/crystal#6250)
- Bootstrap object has been rebuilt and temporarily hosted at
  jcs.org
- Crank stacksize resource limit before building compiler or else it
  will SIGSEGV
- Wrap DESCR at 68

@jcs jcs changed the title from Thread.allocate_stack: Pass MAP_STACK to mmap() on OpenBSD to Thread.allocate_stack: Pass MAP_STACK to mmap() on OpenBSD 6.3+ Jun 27, 2018

@ysbaddaden ysbaddaden merged commit c9f449c into crystal-lang:master Jun 27, 2018

4 checks passed

ci/circleci: test_darwin Your tests passed on CircleCI!
Details
ci/circleci: test_linux Your tests passed on CircleCI!
Details
ci/circleci: test_linux32 Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@ysbaddaden

This comment has been minimized.

Member

ysbaddaden commented Jun 27, 2018

Thank you!

@bcardiff bcardiff added this to the 0.25.1 milestone Jun 27, 2018

wmoxam added a commit to wmoxam/crystal-openbsd-port that referenced this pull request Jul 7, 2018

Update to 0.25.1, shards to 0.8.1 (#13)
* Update to 0.25.0, shards to 0.8.1

- Add MAP_STACK patches which are pending upstream commit
  (crystal-lang/crystal#6250)
- Bootstrap object has been rebuilt and temporarily hosted at
  jcs.org
- Crank stacksize resource limit before building compiler or else it
  will SIGSEGV
- Wrap DESCR at 68

* Update to 0.25.1, now building without patches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment