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

Error: memory access out of bounds in unit test #1112

Closed
bgrgicak opened this issue Mar 18, 2024 · 4 comments · Fixed by #1114
Closed

Error: memory access out of bounds in unit test #1112

bgrgicak opened this issue Mar 18, 2024 · 4 comments · Fixed by #1114
Assignees
Labels
Tests [Type] Bug An existing feature does not function as intended

Comments

@bgrgicak
Copy link
Collaborator

A few unrelated branches (#1083 and #1095) started failing the onMessage > should return null when JS message handler throws an error unit test.

Example error https://github.com/WordPress/wordpress-playground/actions/runs/8324683975/job/22776886035

This error also exists on trunk if you run tests locally, but for some reason, trunk unit tests are passing.

@bgrgicak bgrgicak added [Type] Bug An existing feature does not function as intended Tests labels Mar 18, 2024
This was referenced Mar 18, 2024
@bgrgicak bgrgicak self-assigned this Mar 18, 2024
@bgrgicak
Copy link
Collaborator Author

This test started failing after #1104 was merged.

@bgrgicak
Copy link
Collaborator Author

Log message returned by the failing unit test


stderr | src/test/php.spec.ts > PHP 8.0 > onMessage > should return null when JS message handler throws an error
Failure!
ErrorEvent { isTrusted: [Getter] }
RuntimeError: table index is out of bounds
    at execute_ex (wasm://wasm/02a6d10a:1:6213282)
    ... 4 lines matching cause stack trace ...
    at invoke_vii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7572:3)
    at zend_eval_stringl (wasm://wasm/02a6d10a:1:2118870)
    at zend_eval_string (wasm://wasm/02a6d10a:1:5178042)
    at dynCall_iiii (wasm://wasm/02a6d10a:1:6253311)
    at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24) {
  cause: Error:
      at Object.Asyncify.handleSleep (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7771:49)
      at _js_module_onMessage (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:5861:19)
      at zif_post_message_to_js (wasm://wasm/02a6d10a:1:4711584)
      at ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER (wasm://wasm/02a6d10a:1:6632058)
      at execute_ex (wasm://wasm/02a6d10a:1:6213282)
      at zend_execute (wasm://wasm/02a6d10a:1:2117712)
      at dynCall_vii (wasm://wasm/02a6d10a:1:6251630)
      at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
      at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
      at invoke_vii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7572:3)
}
ErrorEvent { isTrusted: [Getter] }
RuntimeError: memory access out of bounds
    at destroy_op_array (wasm://wasm/02a6d10a:1:573070)
    at dynCall_vi (wasm://wasm/02a6d10a:1:6251802)
    at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
    at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
    at invoke_vi (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7495:3)
    at zend_eval_stringl (wasm://wasm/02a6d10a:1:2119675)
    at zend_eval_string (wasm://wasm/02a6d10a:1:5178042)
    at dynCall_iiii (wasm://wasm/02a6d10a:1:6253311)
    at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
    at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13) {
  cause: Error:
      at Object.Asyncify.handleSleep (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7771:49)
      at _js_module_onMessage (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:5861:19)
      at zif_post_message_to_js (wasm://wasm/02a6d10a:1:4711584)
      at ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER (wasm://wasm/02a6d10a:1:6632058)
      at execute_ex (wasm://wasm/02a6d10a:1:6213282)
      at zend_execute (wasm://wasm/02a6d10a:1:2117712)
      at dynCall_vii (wasm://wasm/02a6d10a:1:6251630)
      at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
      at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
      at invoke_vii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7572:3)
}
ErrorEvent { isTrusted: [Getter] }
RuntimeError: memory access out of bounds
    at dlfree (wasm://wasm/02a6d10a:1:33839)
    at zend_eval_stringl (wasm://wasm/02a6d10a:1:2120090)
    at zend_eval_string (wasm://wasm/02a6d10a:1:5178042)
    at dynCall_iiii (wasm://wasm/02a6d10a:1:6253311)
    at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
    at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
    at invoke_iiii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7539:10)
    at run_php (wasm://wasm/02a6d10a:1:5414169)
    at dynCall_ii (wasm://wasm/02a6d10a:1:6253705)
    at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24) {
  cause: Error:
      at Object.Asyncify.handleSleep (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7771:49)
      at _js_module_onMessage (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:5861:19)
      at zif_post_message_to_js (wasm://wasm/02a6d10a:1:4711584)
      at ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER (wasm://wasm/02a6d10a:1:6632058)
      at execute_ex (wasm://wasm/02a6d10a:1:6213282)
      at zend_execute (wasm://wasm/02a6d10a:1:2117712)
      at dynCall_vii (wasm://wasm/02a6d10a:1:6251630)
      at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
      at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
      at invoke_vii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7572:3)
}
ErrorEvent { isTrusted: [Getter] }
RuntimeError: memory access out of bounds
    at dlfree (wasm://wasm/02a6d10a:1:34180)
    at run_php (wasm://wasm/02a6d10a:1:5414446)
    at dynCall_ii (wasm://wasm/02a6d10a:1:6253705)
    at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
    at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
    at invoke_ii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7528:10)
    at wasm_sapi_handle_request (wasm://wasm/02a6d10a:1:5253084)
    at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
    at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
    at Object.doRewind (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6765:10) {
  cause: Error:
      at Object.Asyncify.handleSleep (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7771:49)
      at _js_module_onMessage (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:5861:19)
      at zif_post_message_to_js (wasm://wasm/02a6d10a:1:4711584)
      at ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER (wasm://wasm/02a6d10a:1:6632058)
      at execute_ex (wasm://wasm/02a6d10a:1:6213282)
      at zend_execute (wasm://wasm/02a6d10a:1:2117712)
      at dynCall_vii (wasm://wasm/02a6d10a:1:6251630)
      at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
      at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
      at invoke_vii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7572:3)
}
ErrorEvent { isTrusted: [Getter] }
RuntimeError: memory access out of bounds
    at dlfree (wasm://wasm/02a6d10a:1:34180)
    at wasm_sapi_request_shutdown (wasm://wasm/02a6d10a:1:3114667)
    at call (wasm://wasm/02a6d10a:1:4012501)
    at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
    at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
    at invoke_v (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7605:3)
    at wasm_sapi_handle_request (wasm://wasm/02a6d10a:1:5253953)
    at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
    at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
    at Object.doRewind (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6765:10) {
  cause: Error:
      at Object.Asyncify.handleSleep (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7771:49)
      at _js_module_onMessage (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:5861:19)
      at zif_post_message_to_js (wasm://wasm/02a6d10a:1:4711584)
      at ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER (wasm://wasm/02a6d10a:1:6632058)
      at execute_ex (wasm://wasm/02a6d10a:1:6213282)
      at zend_execute (wasm://wasm/02a6d10a:1:2117712)
      at dynCall_vii (wasm://wasm/02a6d10a:1:6251630)
      at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
      at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
      at invoke_vii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7572:3)
}
ErrorEvent { isTrusted: [Getter] }
RuntimeError: memory access out of bounds
    at dlfree (wasm://wasm/02a6d10a:1:34180)
    at wasm_sapi_handle_request (wasm://wasm/02a6d10a:1:5254051)
    at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
    at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
    at Object.doRewind (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6765:10)
    at /Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6786:38
    at /Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:5875:5 {
  cause: Error:
      at Object.Asyncify.handleSleep (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7771:49)
      at _js_module_onMessage (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:5861:19)
      at zif_post_message_to_js (wasm://wasm/02a6d10a:1:4711584)
      at ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER (wasm://wasm/02a6d10a:1:6632058)
      at execute_ex (wasm://wasm/02a6d10a:1:6213282)
      at zend_execute (wasm://wasm/02a6d10a:1:2117712)
      at dynCall_vii (wasm://wasm/02a6d10a:1:6251630)
      at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
      at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
      at invoke_vii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7572:3)
}
Error: Rethrown
    at UnhandledRejectionsTarget.errorListener (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/base-php.ts:604:23)
    at UnhandledRejectionsTarget.callTheUserObjectsOperation (/Users/bero/Projects/wordpress-playground/node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30)
    at innerInvokeEventListeners (/Users/bero/Projects/wordpress-playground/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:350:25)
    at invokeEventListeners (/Users/bero/Projects/wordpress-playground/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:286:3)
    at EventTargetImpl._dispatch (/Users/bero/Projects/wordpress-playground/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:233:9)
    at EventTargetImpl.dispatchEvent (/Users/bero/Projects/wordpress-playground/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:104:17)
    at UnhandledRejectionsTarget.dispatchEvent (/Users/bero/Projects/wordpress-playground/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:241:34)
    at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:60:14)
    at invoke_vii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7572:3)
    at zend_eval_stringl (wasm://wasm/02a6d10a:1:2118870) {
  cause: RuntimeError: table index is out of bounds
      at execute_ex (wasm://wasm/02a6d10a:1:6213282)
      ... 4 lines matching cause stack trace ...
      at invoke_vii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7572:3)
      at zend_eval_stringl (wasm://wasm/02a6d10a:1:2118870)
      at zend_eval_string (wasm://wasm/02a6d10a:1:5178042)
      at dynCall_iiii (wasm://wasm/02a6d10a:1:6253311)
      at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24) {
    cause: Error:
        at Object.Asyncify.handleSleep (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7771:49)
        at _js_module_onMessage (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:5861:19)
        at zif_post_message_to_js (wasm://wasm/02a6d10a:1:4711584)
        at ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER (wasm://wasm/02a6d10a:1:6632058)
        at execute_ex (wasm://wasm/02a6d10a:1:6213282)
        at zend_execute (wasm://wasm/02a6d10a:1:2117712)
        at dynCall_vii (wasm://wasm/02a6d10a:1:6251630)
        at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
        at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
        at invoke_vii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7572:3)
  },
  betterMessage: 'table index is out of bounds'
}
Error: table index is out of bounds
    at _NodePHP.#handleRequest (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/base-php.ts:649:21)
    at _NodePHP.run (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/base-php.ts:278:21)
    at /Users/bero/Projects/wordpress-playground/packages/php-wasm/node/src/test/php.spec.ts:1560:16
    at runTest (file:///Users/bero/Projects/wordpress-playground/node_modules/@vitest/runner/dist/index.js:599:11)
    at runSuite (file:///Users/bero/Projects/wordpress-playground/node_modules/@vitest/runner/dist/index.js:708:15)
    at runSuite (file:///Users/bero/Projects/wordpress-playground/node_modules/@vitest/runner/dist/index.js:708:15)
    at runSuite (file:///Users/bero/Projects/wordpress-playground/node_modules/@vitest/runner/dist/index.js:708:15)
    at runFiles (file:///Users/bero/Projects/wordpress-playground/node_modules/@vitest/runner/dist/index.js:759:5)
    at startTests (file:///Users/bero/Projects/wordpress-playground/node_modules/@vitest/runner/dist/index.js:768:3)
    at file:///Users/bero/Projects/wordpress-playground/node_modules/vitest/dist/entry.js:278:7 {
  cause: Error: Rethrown
      at UnhandledRejectionsTarget.errorListener (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/base-php.ts:604:23)
      at UnhandledRejectionsTarget.callTheUserObjectsOperation (/Users/bero/Projects/wordpress-playground/node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30)
      at innerInvokeEventListeners (/Users/bero/Projects/wordpress-playground/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:350:25)
      at invokeEventListeners (/Users/bero/Projects/wordpress-playground/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:286:3)
      at EventTargetImpl._dispatch (/Users/bero/Projects/wordpress-playground/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:233:9)
      at EventTargetImpl.dispatchEvent (/Users/bero/Projects/wordpress-playground/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:104:17)
      at UnhandledRejectionsTarget.dispatchEvent (/Users/bero/Projects/wordpress-playground/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:241:34)
      at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:60:14)
      at invoke_vii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7572:3)
      at zend_eval_stringl (wasm://wasm/02a6d10a:1:2118870) {
    cause: RuntimeError: table index is out of bounds
        at execute_ex (wasm://wasm/02a6d10a:1:6213282)
        ... 4 lines matching cause stack trace ...
        at invoke_vii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7572:3)
        at zend_eval_stringl (wasm://wasm/02a6d10a:1:2118870)
        at zend_eval_string (wasm://wasm/02a6d10a:1:5178042)
        at dynCall_iiii (wasm://wasm/02a6d10a:1:6253311)
        at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24) {
      cause: Error:
          at Object.Asyncify.handleSleep (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7771:49)
          at _js_module_onMessage (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:5861:19)
          at zif_post_message_to_js (wasm://wasm/02a6d10a:1:4711584)
          at ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER (wasm://wasm/02a6d10a:1:6632058)
          at execute_ex (wasm://wasm/02a6d10a:1:6213282)
          at zend_execute (wasm://wasm/02a6d10a:1:2117712)
          at dynCall_vii (wasm://wasm/02a6d10a:1:6251630)
          at ret.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:6682:24)
          at runtime.asm.<computed> (/Users/bero/Projects/wordpress-playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:45:13)
          at invoke_vii (/Users/bero/Projects/wordpress-playground/packages/php-wasm/node/public/php_8_0.js:7572:3)
    },
    betterMessage: 'table index is out of bounds'
  }
}

@bgrgicak
Copy link
Collaborator Author

bgrgicak commented Mar 18, 2024

@adamziel I'm taking a look at this tomorrow, but I will probably need some help to resolve it.

@bgrgicak
Copy link
Collaborator Author

#1114 fixes the issue that was introduced in #1104

adamziel pushed a commit that referenced this issue Mar 19, 2024
Fixes #1112

It fixes a bug in post_message_to_js that broke sending messages in
Node.

## What problem is it solving?

It checks if the response length of a message is larger than -1 before
attempting to process the message.

## How is the problem addressed?

By checking the response length.

## Testing Instructions

- Confirm that all tests pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tests [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant