Skip to content

stylo's build script crashes inside mangling with "(signal: 11, SIGSEGV: invalid memory reference)" on macOS #462

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

Closed
upsuper opened this issue Jan 31, 2017 · 5 comments

Comments

@upsuper
Copy link
Contributor

upsuper commented Jan 31, 2017

See bug 1335302.

After adding "--stdlib=libc++", "--target=x86_64-apple-darwin" to clang args in build_gecko.rs, the bindgen does not report any compile error anymore, but it crashes with the stack I pasted in bug 1335302 comment 3.

I saw #439, and also tested upgrading to clang-sys 0.14.0, but it doesn't seem to help. The build script still crashes at the same location.

It seems to crash when trying to get mangling name of __find_exactly_one_checked::__matches at /usr/local/Cellar/llvm/3.9.0/include/c++/v1/tuple:1018:25. But I failed to find minimal reproducible code...

@upsuper
Copy link
Contributor Author

upsuper commented Jan 31, 2017

@emilio Could you have a look at this? This is probably not really a bindgen bug... It could be a bug in libclang. I have no idea how can we workaround it.

@upsuper
Copy link
Contributor Author

upsuper commented Feb 1, 2017

The issue here is that it somehow doesn't treat __find_exactly_one_checked as a template, hence the cursor.is_in_non_fully_specialized_template() check returns false and consequently we don't correctly skip mangling __find_exactly_one_checked::__matches.

Cursor::is_template's documnet is "Is the referent a template specialization?", which probably shouldn't be named is_template. I guess, maybe we should use is_template_like or something in is_in_non_fully_specialized_template?

@upsuper
Copy link
Contributor Author

upsuper commented Feb 1, 2017

Actually this issue is reproducible with the following code:

template <class... Args>
struct Test {
  static constexpr bool x[] = {Args::x...};
};

@emilio
Copy link
Contributor

emilio commented Feb 1, 2017

Thanks for the testcase! I'll find a workaround ASAP.

(For the record, Xidorn debugged it and it's a bug in LLVM, I think he submitted a patch?)

emilio added a commit to emilio/rust-bindgen that referenced this issue Feb 1, 2017
emilio added a commit to emilio/rust-bindgen that referenced this issue Feb 1, 2017
@upsuper
Copy link
Contributor Author

upsuper commented Feb 1, 2017

It is not necessarily a bug in clang. There is no way in clang itself to hit that condition, and it seems libclang doesn't have no-crashing guarantee for invalid input.

I tried hard to write a test for that issue last night, but failed, so I'm not going to submit a patch for it.

emilio added a commit to emilio/rust-bindgen that referenced this issue Feb 2, 2017
emilio added a commit to emilio/rust-bindgen that referenced this issue Feb 2, 2017
emilio added a commit to emilio/rust-bindgen that referenced this issue Feb 2, 2017
bors-servo pushed a commit that referenced this issue Feb 2, 2017
ir: Fix is_in_non_fully_specialized_template check.

Fixes #462

r? @upsuper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants