Skip to content

fix: clear the fallback myLib when the FFI thread exits - #282

Draft
gmelodie wants to merge 1 commit into
masterfrom
feat/mylib-survives-static-context-teardown
Draft

gmelodie wants to merge 1 commit into
masterfrom
feat/mylib-survives-static-context-teardown

Conversation

@gmelodie

Copy link
Copy Markdown
Collaborator

The {.ffiStatic.} context runs no ctor, so its FFI thread points ctx.myLib at a local in its own closure. After <lib>_shutdown, destroyStaticFFIContext parks that thread and releases the slot, but myLib keeps the dead address. A later <lib>_create reuses the slot, and processQueue keeps a non-nil myLib. For an object lib, a {.ffi.} call queued behind a ctor that awaits then reads freed memory on the FFI thread.

The exit defer of ffiThreadBody now clears myLib when the ctor does not own it, and initContextResources clears it for a slot built from scratch.

@gmelodie

Copy link
Copy Markdown
Collaborator Author

@greptileai review this PR

@gmelodie

Copy link
Copy Markdown
Collaborator Author

/review

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.

1 participant