Skip to content

Resolve crash when performing -replace on AS3 scripts#256

Open
cnnranderson wants to merge 1 commit into
jindrapetrik:devfrom
cnnranderson:bugfix/as3-replace-traits
Open

Resolve crash when performing -replace on AS3 scripts#256
cnnranderson wants to merge 1 commit into
jindrapetrik:devfrom
cnnranderson:bugfix/as3-replace-traits

Conversation

@cnnranderson
Copy link
Copy Markdown

@cnnranderson cnnranderson commented May 1, 2026

This fix was created by a mod author (ttam) on Nexus. I am proposing this fix on their behalf.

From their notes:

When JPEXS replaces a script, it calls pack.delete(abc, true) to remove the old script from the ABC bytecode. That deletion invalidates the constant pool. Multiname indices that other traits were pointing to are now stale. Then JPEXS calls refreshAbc() -> addAbc() -> indexTraits(), which iterates over ALL traits in the ABC (not just the one you replaced). Some of those other traits still have name_index values pointing to the old constant pool positions. When it does abc.constants.getMultiname(t.name_index), the index is out of bounds -> IndexOutOfBoundsException -> crash.

Those stale traits are from deleted/replaced scripts that haven't been cleaned up yet. Skipping them during indexing is safe because they're dead code - they'll never be referenced again. The actual replacement script gets compiled fresh with valid indices.

Drop stale traits that remain from deleted/replaced scripts.
@jindrapetrik
Copy link
Copy Markdown
Owner

I think it will be sufficient to check trait.deleted flag instead of the name indices.
I will update it myself...

@jindrapetrik
Copy link
Copy Markdown
Owner

I have added the deleted condition in f60adad

  • nightly 3501.

Please check it (or ttam), whether it works for you the same way.

@cnnranderson
Copy link
Copy Markdown
Author

cnnranderson commented May 2, 2026

We're double checking today. The reason this approach was used was because of an issue with that flag not being applied consistently. This was the simplest fix to avoid a chain reaction of other fixes that might be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants