Skip to content

[BUG] Incrementing stack pointer leads to auxiliary stack underflow. #4941

@teyahb8

Description

@teyahb8

Describe the bug
The attached PoC results in wasm auxiliary stack underflow error for all modes of WAMR runtime. When __heap_base value becomes less than 5264, the exception no longer occurs.

Version
iwasm 2.4.3
Commit: 4b306f0

To Reproduce
Steps to reproduce the behavior:

  1. Convert the following PoC to wasm:
(module
  (global $__stack_pointer (;0;) (mut i32) i32.const 1)
  (global (;1;) i32 i32.const 5264)
  (global (;2;) i32 i32.const 1)
  (export "__heap_base" (global 1))
  (export "__data_end" (global 2))
  (export "main" (func $main))
  (func $main
    global.get $__stack_pointer
    i32.const 1
    i32.add
    global.set $__stack_pointer
    return
  )
)
  1. Run the following: iwasm -f main poc.wasm

Expected behavior
Should exit with no exception based on other runtimes.

Actual Result
wasm auxiliary stack underflow

Desktop (please complete the following information):

  • Arch [x86_64]
  • OS [Linux]
  • Version [22.04]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions