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

Handled Ruby's exceptions correctly #5

Merged
merged 2 commits into from
May 8, 2019
Merged

Conversation

irxground
Copy link
Contributor

VM::raise_ex is a dangerous function and should be used carefully

Rust has a drop function to release memory, etc. This internal implementation is a feature called unwind. Ruby, on the other hand, uses longjump as an exception. Rust's drop function doesn't work properly when using two functions together. If you throw a Ruby exception in the middle of a Rust program, the following program will not be executed, so a memory leak may occur.

I introduced the unwrap_or_raise function and corrected so that drop will always be executed before a Ruby exception occurs.

@Hywan
Copy link
Contributor

Hywan commented May 7, 2019

Thanks for the PR! It was clearly on my radar, so thank you for doing it.

I'll review the PR as soon as possible. Everything looks good to me so far.

@Hywan Hywan self-assigned this May 7, 2019
@Hywan Hywan added 🎉 enhancement New feature or request 📦 component-extension About the Ruby extension written in Rust labels May 7, 2019
@irxground
Copy link
Contributor Author

I'm sorry. I missed one place.

@Hywan
Copy link
Contributor

Hywan commented May 8, 2019

bors try

Copy link
Contributor

@Hywan Hywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you very much :-).

@Hywan Hywan merged commit a73a24c into wasmerio:master May 8, 2019
@irxground irxground deleted the fix_raise branch May 8, 2019 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 component-extension About the Ruby extension written in Rust 🎉 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants