-
Notifications
You must be signed in to change notification settings - Fork 168
feat!(rust/ffi): catch panics at FFI boundary #3819
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
base: main
Are you sure you want to change the base?
Conversation
e1f661e to
a2d7fc3
Compare
|
also CC @eitsupi if you're interested |
amoeba
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice. I hadn't seen the old behavior so I disabled it and re-ran the new tests and this PR is a big improvement. I had one question and a really tiny nit if you agree.
|
|
||
| #[allow(non_snake_case)] | ||
| #[no_mangle] | ||
| pub unsafe extern "C" fn AdbcDriverInit( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change (L212:220)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a backstop so that the entrypoint can be found. Otherwise you have to declare it manually which is a bit inconvenient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, got it. Thanks.
eitsupi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
I found some points to be improved.
rust/ffi/src/driver_exporter.rs
Outdated
| /// # Parameters | ||
| /// | ||
| /// - `$func_name` - Driver's initialization function name. The recommended name | ||
| /// is `AdbcDriverInit`, or a name derived from the name of the driver's shared |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the documentation needs to be updated to state that "AdbcDriverInit is a reserved name" (no longer be able to used after this change), and perhaps the PR should be renamed to feat(rust/ffi)! ... to make it clear that it is a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I should update that comment...the name should be the latter (a driver should provide both)
|
I think 22b954d needs a slight fix which I'll look at |
This gives a slightly nicer experience than unconditionally crashing the entire program. As with the Go FFI scaffolding, once a driver panics, all further calls to the driver will fail. (Albeit, this is not true for exported readers. We also need our own C Data Interface export shim so we can handle things like exporting ADBC errors through the C Data Interface boundary. Currently, C++ and Go-based drivers can do this.)
Co-authored-by: eitsupi <50911393+eitsupi@users.noreply.github.com>
Co-authored-by: Bryce Mecum <petridish@gmail.com>
Co-authored-by: Bryce Mecum <petridish@gmail.com>
f41b35f to
e3801d0
Compare
This gives a slightly nicer experience than unconditionally crashing the entire program. As with the Go FFI scaffolding, once a driver panics, all further calls to the driver will fail. (Albeit, this is not true for exported readers. We also need our own C Data Interface export shim so we can handle things like exporting ADBC errors through the C Data Interface boundary. Currently, C++ and Go-based drivers can do this.)