Skip to content

WASM/emscripten builds crash in cfg_free() — libconfuse cfg_yylex_destroy signature mismatch #1436

Open

Description

@4fthawaiian

Summary

OpenOMF cross-compiled to WebAssembly (via the openomf-web port) traps at startup inside cfg_free() whenever a mod manifest is parsed. Root cause is a return-type mismatch in the vendored libconfuse dependency, not OpenOMF code.

Root cause

libconfuse ships:

// src/confuse.c
extern void cfg_yylex_destroy(void);   // declaration
...
cfg_yylex_destroy();                   // called from cfg_free()

but the flex-generated lexer defines it as:

// generated lexer (flex >= 2.6)
int yylex_destroy(void)

On native ABIs the mismatched return type is harmless. On WebAssembly the runtime enforces exact signatures, so the call traps (RuntimeError: unreachable). Every modmanager manifest parse hits this during engine_init(), so the game never reaches the main menu.

Reproduction

WASM build with any .zip mod present under data/mods/. Startup log stops at:

Found 6 system mods.
Found 0 user mods.
RuntimeError: unreachable

Fix

Upstream libconfuse PR aligns the declaration with the generated definition:

Until it lands upstream, Emscripten builds need a local patch:

- extern void cfg_yylex_destroy(void);
+ extern int  cfg_yylex_destroy(void);

Notes for this repo

  • Mod support (0.8.6+) relies on cfg_parse_buf/cfg_free, so any future web/emscripten CI is affected.
  • The mismatch is also flagged as a wasm-ld: warning: function signature mismatch: cfg_yylex_destroy at link time — a good canary for CI.

Activity

  1. added theissue type on Sep 10, 2026
  2. katajakasa commented on Sep 10, 2026

    @katajakasa
    Member

    Noted. Looks like this simply requires a version update for libconfuse from our side, when libconfuse gets v3.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions