Skip to content

Commit e8b162d

Browse files
author
Mark McCaskey
committed
Fix abort and _abort to be different
1 parent cd946f1 commit e8b162d

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

lib/emscripten/src/exception.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub fn ___cxa_rethrow_primary_exception(_ctx: &mut Ctx, _a: u32) {
3333
pub fn ___cxa_throw(ctx: &mut Ctx, _ptr: u32, _ty: u32, _destructor: u32) {
3434
debug!("emscripten::___cxa_throw");
3535
eprintln!("Throwing exceptions not yet implemented: aborting!");
36-
_abort(ctx, 0);
36+
_abort(ctx);
3737
}
3838

3939
pub fn ___cxa_begin_catch(_ctx: &mut Ctx, _exception_object_ptr: u32) -> i32 {

lib/emscripten/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
731731
"___syscall345" => func!(crate::syscalls::___syscall345),
732732

733733
// Process
734-
"abort" => func!(crate::process::_abort),
734+
"abort" => func!(crate::process::em_abort),
735735
"_abort" => func!(crate::process::_abort),
736736
"_prctl" => func!(crate::process::_prctl),
737737
"abortStackOverflow" => func!(crate::process::abort_stack_overflow),

lib/emscripten/src/process.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ use wasmer_runtime_core::vm::Ctx;
1010
pub fn abort_with_message(ctx: &mut Ctx, message: &str) {
1111
debug!("emscripten::abort_with_message");
1212
println!("{}", message);
13-
_abort(ctx, 0);
13+
_abort(ctx);
1414
}
1515

16-
pub fn _abort(_ctx: &mut Ctx, arg: u32) {
16+
/// The name of this call is `abort` but we want to avoid conflicts with libc::abort
17+
pub fn em_abort(ctx: &mut Ctx, arg: u32) {
18+
debug!("emscripten::abort");
19+
eprintln!("Program aborted with value {}", arg);
20+
_abort(ctx);
21+
}
22+
23+
pub fn _abort(_ctx: &mut Ctx) {
1724
debug!("emscripten::_abort");
18-
if arg != 0 {
19-
eprintln!("Program aborted with value {}", arg);
20-
}
2125
unsafe {
2226
abort();
2327
}

0 commit comments

Comments
 (0)