Skip to content

"memory access error" when building Machine in web assembly #3196

@alexpetros

Description

@alexpetros

Description

I'm having difficulty getting this library to work with wasm compilation.. It throws an exception when creating the Machine object.

For what it's worth, I first encountered this error when using MachineBuilder in rust code that I was compiling to wasm, but this example is simpler.

Apologies if I missed an issue/bug template, I couldn't find one! Happy to edit for provide more information as necessary. I'm a big fan of this project, and have been excited about giving wasm prolog a spin for a while.

Reproduction

Compiled on an M1 MacBook Pro, running MacOS 26.1

  1. Clone the repository
  2. Run wasm-pack build --target web -- --no-default-features
  3. Create an index.html with the example sudoku solver
  4. Open it with a web server

In Firefox:

Uncaught RuntimeError: index out of bounds
    build http://localhost:3000/pkg/scryer_prolog.js:272
    <anonymous> http://localhost:3000/:16

In Chrome:

Uncaught RuntimeError: memory access out of bounds
    at 011abea2:0x303b9e
    at 011abea2:0x2e1128
    at 011abea2:0x85bd
    at 011abea2:0x2b8ea7
    at MachineBuilder.build (scryer_prolog.js:272:26)
    at (index):16:46

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions