cocos-engine icon indicating copy to clipboard operation
cocos-engine copied to clipboard

Memory access out of bounds in spine 4.2

Open Arenooo opened this issue 3 months ago • 6 comments

Cocos Creator version

3.8.7

System information

Windows 11

Issue description

Memory access out of bounds error in spine 4.2 when setting complete listener in onLoad() with 0 frame animation playing by default and accessing trackEntry.animation.name in listener callback

Relevant error log output

RuntimeError: memory access out of bounds at null. (wasm://wasm/0010675a:1:25266) at Ha.name (C:\ProgramData\cocos\editors\Creator\3.8.7\resources\resources\3d\engine\native\external\emscripten\spine\4.2\spine.wasm.js:52:285) at TrackEntryListeners.complete (hidden) at Function.emitListener (C:\ProgramData\cocos\editors\Creator\3.8.7\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:58266:26) at vb (C:\ProgramData\cocos\editors\Creator\3.8.7\resources\resources\3d\engine\native\external\emscripten\spine\4.2\spine.wasm.js:38:280) at null. (wasm://wasm/0010675a:1:146685) at null. (wasm://wasm/0010675a:1:202289) at null. (wasm://wasm/0010675a:1:29021) at Ha.eval [as updateAnimation] (C:\ProgramData\cocos\editors\Creator\3.8.7\resources\resources\3d\engine\native\external\emscripten\spine\4.2\spine.wasm.js:31:49) at Skeleton.updateAnimation (C:\ProgramData\cocos\editors\Creator\3.8.7\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:59572:28) at eval (C:\ProgramData\cocos\editors\Creator\3.8.7\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:58179:22) at Set.forEach () at SkeletonSystem.postUpdate (C:\ProgramData\cocos\editors\Creator\3.8.7\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:58178:27) at Director.tick (C:\ProgramData\cocos\editors\Creator\3.8.7\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:88695:34) at Game._updateCallback (C:\ProgramData\cocos\editors\Creator\3.8.7\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:89756:22) at updateCallback (C:\ProgramData\cocos\editors\Creator\3.8.7\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:85737:20) at sentryWrapped (C:\ProgramData\cocos\editors\Creator\3.8.7\resources\app.asar\node_modules@sentry\browser\src\helpers.ts:116:17)

Steps to reproduce

Steps to reproduce:

1 - create a prefab with sp.Skeleton component attached 2 - set a 0 frame animation on the skeleton component on the prefab to play automatically when instantiated 3 - attach a script that will set a listener via skeleton.setCompleteListener in onLoad() function and access the trackEntry.animation.name property 3 - instantiate the prefab and set parent to add to scene 4 - observe the error

onLoad(): void {
        this.skeleton.setCompleteListener((data) => {
            switch (data.animation.name) { // will cause the error
                case 'impact':
                    this.setIdle();
                    break;
                case 'match':
                    this._matchResolve();
                    this.setIdle();
                    break;
            }
        });
    }
Image Image Image

Minimal reproduction project

No response

Arenooo avatar Sep 27 '25 20:09 Arenooo

Please have a try: 1.switch spine version in project setting. 2.close project, delete library and temp. 3.open the project again.

tangkaikk avatar Oct 13 '25 08:10 tangkaikk

try this PR: https://github.com/cocos/cocos-engine/pull/19041

finscn avatar Oct 20 '25 11:10 finscn

@Arenooo Could you upload your demo?

bofeng-song avatar Nov 19 '25 09:11 bofeng-song

package.zip

tangkaikk avatar Nov 20 '25 06:11 tangkaikk

@Arenooo @finscn @tangkaikk Synchronized the official code, SkeletonBinary It is necessary to check the resources for any slots that lack attachments.

bofeng-song avatar Nov 20 '25 07:11 bofeng-song

@Arenooo @finscn @tangkaikk Synchronized the official code, SkeletonBinary It is necessary to check the resources for any slots that lack attachments.

这个 代码我合过来了. 但是感觉和现在的差异很大, 不知道里面是不是有 cocos 不需要的代码.

另外, 还是建议合并一下我这个 PR #19041 . 我是合并这个之后 问题就解决了. 不合并这个 有点类似于无限嵌套调用.

finscn avatar Nov 22 '25 04:11 finscn