ensure function args outlive prepare_call helper #161
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have a suspicious failing test:
We expect the number
16
to be passed to our JavaScript function but it's mostly being passed0
. I say mostly because sometimes it's a random number. 😳I've also witnessed random segmentation faults when running tests such as:
It turned out that when we pass
args
to theprepare_call
helper, that values were being freed at the end of it's scope. The docs foras_mut_ptr
have a clue about this:With the help of @alexcrichton, we now pass
prepare_call
a reference instead which allows the value to live long enough.The segmentation fault seems to be resolved too, which makes sense. I haven't seen it since implementing this change.
Update: I believe this bug was introduced in 7fc8d98 when some logic in
JsFunction::call
was abstracted out intoprepare_call
to support #61.