Skip to content

Abort in a WASIX thread causes an exit with exitcode 0 #5904

@zebreus

Description

@zebreus

Describe the bug

Calling the WASIX abort() function (which is just a wrapper around __builtin_trap) from a thread causes the wasmer to exit with code 0. The exitcode should actually be non-zero. Calling __builtin_trap from the main thread works and has a non-zero exit code.

Steps to reproduce

Compile the following code to wasix WASM

#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <pthread.h>

#ifndef NULL
#define NULL ((void*)0)
#endif

void* abort_in_thread(void* arg) {
    // Abnormal termination should never result in exit code 0
    abort();
}

int main() {
    pthread_t thread;
    pthread_create(&thread, NULL, abort_in_thread, NULL);
    pthread_join(thread, NULL);

    return 5;
}

Then run it with wasmer

Expected behavior

Exit with a non-zero exit code

Actual behavior

Exits with exitcode zero

Additional context

Calling abort in the main thread works as intended

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions