-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Handle failure in ffi_closure_alloc
#1378
Handle failure in ffi_closure_alloc
#1378
Conversation
I had a bit of a look for tests of similar things but didn't see anything obvious, nor can I think of good ways to test this change. Some guidance would be appreciated. |
Looks like a fix for #1107. |
Change looks good to me. Thank you. I agree testing this will be difficult to impossible. You could startup a virtual machine, lock that down, test to run JNA in that setup and observe what happens. I think that the balance between effort and results would tip in a bad way, so I think review is enough here. Could please also have a look at: Lines 3515 to 3535 in a40db1b
Lines 3527 and 3529 look pretty similar, so I think a guard should be placed there also. |
Sure, I think bb75249 does the right thing here. |
Eyeballed this and looks good to me. To get this in please squash the changes into a single commit. After merge I'll see which architectures I manage to rebuild. |
`ffi_closure_alloc` may fail and return `NULL` if, for instance, we're running in a locked-down operating system that forbids FFI from allocating executable pages of memory in any of the ways that it tries. Today we pass this `NULL` on to `ffi_prep_closure_loc` which triggers a segmentation fault that takes down the whole JVM. With this change we check for a failure in this call and turn it into an `UnsupportedOperationException` so that the caller can handle it more gracefully. Relates elastic/elasticsearch#73309 Relates elastic/elasticsearch#18272
5299bd5
to
3f5e937
Compare
Sure thing. The squashed commit is 3f5e937. |
Thank you. |
ffi_closure_alloc
may fail and returnNULL
if, for instance, we'rerunning in a locked-down operating system that forbids FFI from
allocating executable pages of memory in any of the ways that it tries.
Today we pass this
NULL
on toffi_prep_closure_loc
which triggers asegmentation fault that takes down the whole JVM. With this change we
check for a failure in this call and turn it into an
UnsupportedOperationException
so that the caller can handle it moregracefully.
Relates elastic/elasticsearch#73309
Relates elastic/elasticsearch#18272
Closes #1107