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

Task failure aborts app on OS X 10.9 #6849

Closed
lilyball opened this issue May 31, 2013 · 14 comments · Fixed by #10013
Closed

Task failure aborts app on OS X 10.9 #6849

lilyball opened this issue May 31, 2013 · 14 comments · Fixed by #10013
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@lilyball
Copy link
Contributor

A failed assertion inside a task::try aborts on 10.9 with the following error:

libc++abi.dylib: terminating with uncaught exception of type rust_task*
fish: Job 1, './myprog' terminated by signal SIGABRT (Abort)

This appears to be due to the fact that libc++abi is different in 10.9 than in 10.8.

@lilyball
Copy link
Contributor Author

Current belief is that the task_info for rust_task* is non-exported, which means a rust_task* cannot be thrown across library boundaries. This is evidenced by the fact that nm librustrt.dylib says

0000000000033940 d __ZTIP9rust_task

This worked on 10.8 due to bugs in the libc++abi that is used there. I don't know why this works on Linux.

@lilyball
Copy link
Contributor Author

After modifying rustrt.def.in to export _ZTIP9rust_task, the failure still occurs, so there must be something else going on.

@brson
Copy link
Contributor

brson commented Jun 28, 2013

@kballard Does it work if you change the throw type to an int instead of a rust_task*?

@lilyball
Copy link
Contributor Author

@brson No. Throwing an intptr_t just gave me the error

libc++abi.dylib: terminating with uncaught exception of type long

@brson
Copy link
Contributor

brson commented Jul 3, 2013

Not going to be fixed for 0.7

@pnkfelix
Copy link
Member

mmm. OS X support for 10.9 seems important. Nominating for Maturity Milestone #3, Feature Complete.

@catamorphism
Copy link
Contributor

Accepted for milestone 3, feature-complete

@bdash
Copy link
Contributor

bdash commented Sep 27, 2013

This appears to happen because OS X's libunwind is unable to unwind through rust_begin_unwind due to it being unable to find a corresponding entry in the compact or DWARF unwind sections. This is due to the linker failing to preserve DWARF unwind info when passed -no_compact_unwind on OS X 10.9.

@bdash
Copy link
Contributor

bdash commented Sep 27, 2013

Removing -no_compact_unwind fixes this problem since the linker correctly preserves the compact unwind info from the object files when generating the final linked image. This flag was added in cb5f636 to address a problem with the unwind information for __morestack, which is not compatible with the compact unwind format. It's not clear from that change how the problem manifests, but I didn't observe any problems after removing -no_compact_unwind. It's possible that whatever problem that is working around is only an issue on prior versions of OS X.

@bdash
Copy link
Contributor

bdash commented Sep 28, 2013

And for sake of completeness, if removing -no_compact_unwind is not an option then -keep_dwarf_unwind can be used to force the linker to preserve the DWARF unwind information. I wrote up rdar://problem/15096695 about it not happening automatically when -no_compact_unwind is specified since the current behavior on OS X 10.9 appears to be a bug.

@pnkfelix
Copy link
Member

@bdash wrote this:

It's not clear from that change how the problem manifests, but I didn't observe any problems after removing -no_compact_unwind

Is __morestack part of our segmented stack mechanism? (Which is currently disabled, and thus bugs injected into it would be masked/unobservable at the moment?)

@bdash
Copy link
Contributor

bdash commented Oct 19, 2013

I've since learnt that there's a specific pattern that can be emitted in the DWARF CIE or FDE that will inform the OS X linker it shouldn't attempt to convert the DWARF unwind information to its compact unwind format. The pattern the linker looks for is the return address register being saved twice to the same location. This looks like it should be easy to accommodate in __morestack, but I'm hesitant to submit a patch if I'm not able to test that path. Is there some way to test with the segmented stack mechanism enabled on OS X?

@lilyball
Copy link
Contributor Author

OS X 10.9 is probably going to come out in 2 days. This should be fixed now if possible.

@alexcrichton
Copy link
Member

Right now we don't have segmented stacks enabled, but we recently did indeed enable use of __morestack. @bdash, if you have a patch I can see if we can unwind through __morestack locally, although I won't be running on 10.9 (I've got 10.8)

bors added a commit that referenced this issue Oct 22, 2013
OS X 10.9's linker has a bug that results in it failing to preserve
DWARF unwind information when passed the -no_compact_unwind flag.
This flag is passed on OS X because the unwind information for
__morestack cannot be represented by the compact unwind format.

We can work around this problem by using a more targeted approach
to disabling compact unwind information. The OS X linker looks for
a particular pattern in the DWARF unwind information and will not
attempt to convert the unwind information to the compact format.
The pattern in question is the return address register being saved
twice to the same location.

Fixes #6849.
@bors bors closed this as completed in fd8c06e Oct 22, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Mar 11, 2021
Dogfood and CI fixes

The CI fix is practically rust-lang#6829 rebased and squashed into one commit

Dogfood fix is a follow up of rust-lang#6802

r? `@matthiaskrgr` for lintcheck changes

(best reviewed with whitespace changes hidden)

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants