Skip to content

Commit

Permalink
Fix abort and _abort to be different
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark McCaskey committed Dec 2, 2019
1 parent cd946f1 commit e8b162d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/emscripten/src/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn ___cxa_rethrow_primary_exception(_ctx: &mut Ctx, _a: u32) {
pub fn ___cxa_throw(ctx: &mut Ctx, _ptr: u32, _ty: u32, _destructor: u32) {
debug!("emscripten::___cxa_throw");
eprintln!("Throwing exceptions not yet implemented: aborting!");
_abort(ctx, 0);
_abort(ctx);
}

pub fn ___cxa_begin_catch(_ctx: &mut Ctx, _exception_object_ptr: u32) -> i32 {
Expand Down
2 changes: 1 addition & 1 deletion lib/emscripten/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"___syscall345" => func!(crate::syscalls::___syscall345),

// Process
"abort" => func!(crate::process::_abort),
"abort" => func!(crate::process::em_abort),
"_abort" => func!(crate::process::_abort),
"_prctl" => func!(crate::process::_prctl),
"abortStackOverflow" => func!(crate::process::abort_stack_overflow),
Expand Down
14 changes: 9 additions & 5 deletions lib/emscripten/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ use wasmer_runtime_core::vm::Ctx;
pub fn abort_with_message(ctx: &mut Ctx, message: &str) {
debug!("emscripten::abort_with_message");
println!("{}", message);
_abort(ctx, 0);
_abort(ctx);
}

pub fn _abort(_ctx: &mut Ctx, arg: u32) {
/// The name of this call is `abort` but we want to avoid conflicts with libc::abort
pub fn em_abort(ctx: &mut Ctx, arg: u32) {
debug!("emscripten::abort");
eprintln!("Program aborted with value {}", arg);
_abort(ctx);
}

pub fn _abort(_ctx: &mut Ctx) {
debug!("emscripten::_abort");
if arg != 0 {
eprintln!("Program aborted with value {}", arg);
}
unsafe {
abort();
}
Expand Down

0 comments on commit e8b162d

Please sign in to comment.