From e8b162df06f2eac137f76883dce5a76f7d63d106 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Mon, 2 Dec 2019 15:32:14 -0800 Subject: [PATCH] Fix abort and _abort to be different --- lib/emscripten/src/exception.rs | 2 +- lib/emscripten/src/lib.rs | 2 +- lib/emscripten/src/process.rs | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/emscripten/src/exception.rs b/lib/emscripten/src/exception.rs index f2d8d1b1528..74c83437890 100644 --- a/lib/emscripten/src/exception.rs +++ b/lib/emscripten/src/exception.rs @@ -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 { diff --git a/lib/emscripten/src/lib.rs b/lib/emscripten/src/lib.rs index 7dc808bde2b..49767708bbe 100644 --- a/lib/emscripten/src/lib.rs +++ b/lib/emscripten/src/lib.rs @@ -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), diff --git a/lib/emscripten/src/process.rs b/lib/emscripten/src/process.rs index bb42056f1af..7592e070822 100644 --- a/lib/emscripten/src/process.rs +++ b/lib/emscripten/src/process.rs @@ -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(); }