Skip to content

Replace assertions with proper error handling in emitter and verifier #85

Description

@byeongjee

Problem

Several places use assert() for error conditions that can occur at runtime:

  1. WasmStackEmitter.cpp:106assert(!emitter.labelStack.empty() && ...)
  2. VerifyWasmStack.cpp:312assert(ctx && "MLIRContext not initialized")

Why this matters

assert() is stripped in release builds (-DNDEBUG). If these conditions are hit in a release build:

  • Case 1: Proceeds with invalid state, causing undefined behavior
  • Case 2: Null pointer dereference

Expected behavior

Replace assert() with proper error handling using emitError() / return failure() so that invalid states are caught regardless of build configuration.

Location

  • lib/wasmstack/WasmStackEmitter.cpp, line 106
  • lib/wasmstack/VerifyWasmStack.cpp, line 312

Activity

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

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions