You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Possible memory leak: wrapError passes C.CString(message) to wrap_result_error and never frees it #54
wrap_result_error (pkg/janet/api.c:14-21) builds janet_wrap_string(janet_cstring(message)), which copies the bytes into a Janet string, so the C.CString buffer is not referenced after the call. It is never freed.
wrapError is called from poll (module.go:128-131) whenever a Go callback registered through VM.Callback / VM.Module returns a non-nil error. Each such error leaves len(err.Error())+1 bytes allocated in the running server.
Reproduction
A small program using this package (macOS arm64, Go 1.27) registers a callback that always returns a 100-byte error and calls it N times through ExecuteCall. Counting live blocks with heap on the paused process, the 112-byte bucket grew by 905 for 900 additional calls and by 924 for 1000 more (one block per failing call). With a callback that returns nil it stayed flat. With the fix below, leaks --atExit at N=1000 reports no 112-byte blocks.
Activity