Skip to content

Why is my host app's crash stack trace overwritten/lost when Wasmtime is embedded? #11344

@liupeidong0620

Description

@liupeidong0620

Description

I'm embedding wasmtime as a library in my host application to run WebAssembly plugins. However, when my host program encounters a fatal signal (e.g., SIGSEGV) and should generate a core dump, the signal is being intercepted by wasmtime's internal signal handling mechanism. This prevents the default core dump generation and makes it difficult to capture the actual crash stack trace for debugging.

How can I properly configure signal handling so that different signals (especially fatal ones like SIGSEGV, SIGABRT) are handled correctly—allowing the host application to generate core dumps and print stack information as expected, while still allowing wasmtime to handle WebAssembly-related traps?

wasmtime version

wasmtime-v30.0.2-x86_64-linux-c-api.tar.xz

linux system

# uname -a
Linux 384a4bbb-d3bb-4a96-ae4e-5529fd44a702 3.10.0-1062.9.1.el7.x86_64 #1 SMP Fri Dec 6 15:49:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

Code initialization process

int main() {
....
// init wasmtime

// Capture exception signals and print stack information
#ifndef _WIN32
  ::google::InstallFailureSignalHandler();
  ::google::InstallFailureWriter([](const char* data, int size) {
    LOG(ERROR) << "Failure:" << std::string(data, size);
    google::FlushLogFiles(google::INFO);
    google::FlushLogFiles(google::WARNING);
    google::FlushLogFiles(google::ERROR);
    google::FlushLogFiles(google::FATAL);
  });
#endif
}

The host app's coredump stack information is incorrect.

E0728 10:17:07.475342 108776 main.cpp:124] Failure:*** Aborted at 1753669027 (unix time) try "date -d @1753669027" if you are using GNU date ***
E0728 10:17:07.477213 108776 main.cpp:124] Failure:PC: @                0x0 (unknown)
E0728 10:17:07.477321 108776 main.cpp:124] Failure:*** SIGSEGV (@0xffffffffffffffef) received by PID 108417 (TID 0x7fa9931ff700) from PID 18446744073709551599; stack trace: ***
E0728 10:17:07.479700 108776 main.cpp:124] Failure:    @           0xf311f0 wasmtime::runtime::vm::sys::unix::signals::trap_handler::hfe532cb8288e83d6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions