Skip to content

__wasm_call_dtors for reactors #593

@SBKarr

Description

@SBKarr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions