Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on long-running Simnet sessions #1636

Open
BowTiedRadone opened this issue Jan 2, 2025 · 0 comments
Open

Crash on long-running Simnet sessions #1636

BowTiedRadone opened this issue Jan 2, 2025 · 0 comments

Comments

@BowTiedRadone
Copy link

BowTiedRadone commented Jan 2, 2025

Describe the Bug
In long-running sessions, a crash occurs after exactly 3,670,015 iterations with one of the following errors:

  • Recursive use of an object detected which would lead to unsafe aliasing in Rust
  • RuntimeError: unreachable

This issue has been present for a while. Thanks to @hugocaillard’s work in #1617, included in clarinet-sdk version v2.12.0, the issue was mitigated, and performance was significantly improved, allowing roughly twice as many iterations. However, the crash still occurs. Discussions with Hugo suggest this issue is strongly related to memory usage, specifically the Node.js process running the clarinet-sdk session reaching 4 GB of memory at the crash point.

This issue is being opened to facilitate further investigation and in response to reports by users of Rendezvous, which highlights the same crash.


To Reproduce
Steps to reproduce the issue:

  1. Initialize a new Clarinet project:

    clarinet new demo
  2. Create a new file named index.js in the root of the project and add the following code:

    import { initSimnet } from "@hirosystems/clarinet-sdk";
    
    const longRunningSimnetSession = async () => {
      const simnet = await initSimnet();
    
      while (true) {
        simnet.mineEmptyBlock();
        console.log(`Iteration ${simnet.blockHeight}`);
      }
    };
    
    await longRunningSimnetSession();
  3. Install the required dependencies:

    npm install
  4. Run the long-running session:

    node index.js
  5. Observe the crash after exactly 3,670,015 iterations. At this point, Node.js reports 4 GB of memory usage:

    Iteration 3670015
    wasm://wasm/01dccebe:1
    
    RuntimeError: unreachable
        at wasm://wasm/01dccebe:wasm-function[5048]:0x4f80f0
        at wasm://wasm/01dccebe:wasm-function[4373]:0x47ad83
        at wasm://wasm/01dccebe:wasm-function[437]:0x2046aa
        at wasm://wasm/01dccebe:wasm-function[1460]:0x351032
        at wasm://wasm/01dccebe:wasm-function[191]:0x142fd4
        at wasm://wasm/01dccebe:wasm-function[838]:0x2a1337
        at wasm://wasm/01dccebe:wasm-function[4394]:0x47afd4
        at wasm://wasm/01dccebe:wasm-function[3033]:0x42db2d
        at Proxy.mineEmptyBlock (/Users/demo/node_modules/@hirosystems/clarinet-sdk-wasm/clarinet_sdk.js:687:26)
        at longRunningSimnetSession (file:///Users/demo/index.js:7:12)
    
    Node.js v22.11.0
    

Additional Context
The issue consistently occurs after the same number of Simnet iterations (3,670,015) in any app, producing one of the mentioned error messages. See the related issue in Rendezvous. Thanks to @fariedt and @hassan-truscova for highlighting this in Rendezvous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant