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

asmjs TransactionBuilder.min_fee() crash #631

Closed
dractw opened this issue Jun 23, 2023 · 3 comments · Fixed by #632
Closed

asmjs TransactionBuilder.min_fee() crash #631

dractw opened this issue Jun 23, 2023 · 3 comments · Fixed by #632

Comments

@dractw
Copy link
Contributor

dractw commented Jun 23, 2023

Calling TransactionBuilder.min_fee() few times causing asmjs library to crash until whole asmjs module is reloaded.

Steps to reproduce:

const txBuilder = asm.TransactionBuilder.new(txBuilderConfig)
    const receiver = asm.Address.from_bech32(address)

    txBuilder.add_output(
      asm.TransactionOutput.new(
        receiver,
        asm.Value.new(asm.BigNum.from_str(String(amount))),
      )
    )

    outputs.forEach((out) => {
      this.addUtxoInput(txBuilder, out)
    })

    txBuilder.set_ttl(ttl + defaultTtlOffset)

    if (certs) {
      txBuilder.set_certs(certs)
    }

    return txBuilder.min_fee().to_str()

Execution of code above few times (around 3-5) went OK, but suddenly it throws with
Failed to execute 'decode' on 'TextDecoder': the encoded data was not valid. and after that none of asmjs module methods or instances are working until reaload whole module.

Just for example:
image

Can be related: emscripten-core/emscripten#18034

@lisicky
Copy link
Contributor

lisicky commented Jun 27, 2023

Hi @dractw ! We are investigating the issue. As workaround you can try to call free() on each CSL object that you don't need. Or use browser version.

@dractw
Copy link
Contributor Author

dractw commented Jun 30, 2023

@lisicky Hi, i tried your suggestion, unfortunately no luck, it still crashes with Failed to execute 'decode' on 'TextDecoder': the encoded data was not valid. error.
Futhermore, i found that crash also happens after calling txBuilder.add_change_if_needed() with undefined error in catch(e)

@lisicky lisicky linked a pull request Jul 5, 2023 that will close this issue
@lisicky
Copy link
Contributor

lisicky commented Jul 5, 2023

@dractw fix on the way. But anyway if you got the error again, you probably didn't free all CSL objects. A CSL object doesn't free resources on GC. This package might help to prevent memory leaks https://www.npmjs.com/package/csl-runtime-gc

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 a pull request may close this issue.

2 participants