cranelift: improve syscall error/oom handling in JIT module (#5173)
* cranelift: improve syscall error/oom handling in JIT module The JIT module has several places where it `expect`s or `panic`s on syscall or allocator errors. For example, `mmap` and `mprotect` can fail if Linux `vm.max_map_count` is not high enough, and some users may wish to handle this error rather than immediately crashing. This commit plumbs these errors upward as new `ModuleError` types, so that callers of jit module functions like `finalize_definitions` and `define_function` can handle them (or just `unwrap()`, as desired). * cranelift: Remove ModuleError::Syscall variant Syscall errors can just be folded into the generic Backend error, which is an anyhow::Error * cranelift-jit: return io::ErrorKind::OutOfMemory for alloc failure Just using `io::Error::last_os_error()` is not correct as global allocator impls are not required to set errno
This commit is contained in:
@@ -244,7 +244,7 @@ impl TestFileCompiler {
|
||||
// Finalize the functions which we just defined, which resolves any
|
||||
// outstanding relocations (patching in addresses, now that they're
|
||||
// available).
|
||||
self.module.finalize_definitions();
|
||||
self.module.finalize_definitions()?;
|
||||
|
||||
Ok(CompiledTestFile {
|
||||
module: Some(self.module),
|
||||
|
||||
Reference in New Issue
Block a user