WebAssembly / WebAssembly/WASI

__wasm_call_dtors for reactors

Open
#593 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P-cli S-inactive
Dominant language
Rust
Stars
5.8k
Forks
333
Avg merge
2d 13h
Merged PRs (30d)
3

Description

Example usage model:

  • Host app instantiates module, run _initialize/__wasm_call_dtors
  • Calls some functions
  • Closes the module, run /__wasm_call_dtors to release resources correctly

In current model, commands should not preserve state, it's one-call entities

Reactors can be initialised then called multiple times, but it's rely on root command for destructors. If we define dtors in reactor itself, it can broke command, that uses it.

For now, clang from wasi-sdk-21 (Rust too?) do not emits destructors code for reactor at all, only registers with __cxa_atexit. There should be a way to deinstantiate that type of module correctly. Maybe, some compiler flag on another exec model?

Upd: Ok, if i define some function, that calls __wasm_call_dtors directly, with -mexec-model=reactor it works as expected. Is it well-defined behavior? lld do not checks, that function is somehow exported, and can just strip it with '-Os', but leave __wasm_call_dtors in place.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reactor lifecycle described in the issue, including _initialize, __wasm_call_dtors, __cxa_atexit, -mexec-model=reactor, and lld's stripping behavior. Determine the intended deinstantiation and export semantics for reactors without breaking command modules. Done means the behavior is specified and the compiler/linker handling is agreed upon.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
compilers, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.