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(ext/ffi): don't panic in dlopen #12344

Merged
merged 5 commits into from
Oct 7, 2021
Merged

Conversation

littledivy
Copy link
Member

bug introduced in #12301

@littledivy littledivy marked this pull request as draft October 6, 2021 05:40
@littledivy littledivy marked this pull request as ready for review October 6, 2021 05:57
@@ -370,7 +369,12 @@ where
let permissions = state.borrow_mut::<FP>();
permissions.check(&path)?;

let lib = Library::open(&path).map_err(|e| anyhow!(format_error(e, path)))?;
Copy link
Member

Choose a reason for hiding this comment

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

Why was this causing a panic?

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/denoland/deno/blob/main/cli/errors.rs#L33
Alternative would be to add a dlopen::Error::OpeningLibraryError downcast there.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is already a downcast for dlopen::Error

deno/runtime/errors.rs

Lines 161 to 164 in 8705292

.or_else(|| {
e.downcast_ref::<dlopen::Error>()
.map(get_dlopen_error_class)
})

This PR just re-constructs dlopen::Error::OpeningLibraryError after formatting happens so it can be downcast-ed and not panic.

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @littledivy!

@dsherret dsherret merged commit ab2e0a4 into denoland:main Oct 7, 2021
@littledivy littledivy deleted the ffi_dont_panic branch October 7, 2021 15:05
bartlomieju pushed a commit to bartlomieju/deno that referenced this pull request Oct 10, 2021
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

Successfully merging this pull request may close these issues.

3 participants