Repository navigation
Conversation
- continueFiber: unroot the fiber once it stops with any signal other than USER5 (only USER5 fibers are resumed later); also unroot on the early returns in handleCallback, and queue the release in the context-cancel branch after reporting the error. - handleCodeResult runs off the VM thread, so release values with Free() (which unroots on the VM thread) instead of unroot(), including the string and unexpected-type paths; reuse the VM-thread root on out for the new env and free the old env. - ExecuteFunction: free out.Yield and the unmarshalled function. Fixes cfoust#55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #55.
Changes in
pkg/janet:continueFiber: unroot the fiber when it stops with any signal other thanJANET_SIGNAL_USER5. Only USER5 fibers are resumed later (throughresolveRequest), and they come back throughcontinueFiber, so they are released then. The early returns inhandleCallbackunroot too; the context-cancel branch reports the error first and then queues the release withFree(), since it runs off the VM thread.handleCodeResultruns in the goroutine started byrunCode, not on the VM thread, so it now releases values withFree()(which unroots on the VM thread) instead ofunroot(). That includes the string and unexpected-type paths, which previously did not releaseoutat all. ForUpdateEnv, the new env reusesout(already rooted on the VM thread incontinueFiber) and the old env is freed. A*Tablepreviously returned byEnv()is then marked freed;cmd/docsre-readsEnv()on each callback, so it is not affected.ExecuteFunction: freeout.Yieldand the unmarshalled*Function.Root counts after 1000 calls, measured with a debug-instrumented copy that forces a collection on the VM thread before counting:
ExecuteCall(success)ExecuteCall(Janet error)Function.Call(key binding)ExecuteFunctiongo test ./pkg/janet/passes with and without-race.Not changed here: the
v.envwrite inhandleCodeResultstill happens off the VM thread, so concurrentUpdateEnvcalls still race on it (see #55).