Repository navigation
Bound native group keys and channels - #256
Merged
Merged
Conversation
|
All clear! No issues remaining. 🎉 3 issues already resolved
All CI checks passed on
Select any unchecked box below to run or rerun that agent. Passed (1)Full resultsIndent Review Agent
|
highesttt
force-pushed
the
highest/evict-group-keys
branch
from
October 5, 2026 16:05
d764156 to
dc51cc6
Compare
highesttt
changed the base branch from
iFixRobots/own-line-crypto-runtimes
to
iFixRobots/fix-native-group-key-ownership
October 5, 2026 16:05
highesttt
force-pushed
the
highest/evict-group-keys
branch
2 times, most recently
from
October 5, 2026 16:37
1868051 to
451152c
Compare
Base automatically changed from
iFixRobots/fix-native-group-key-ownership
to
main
October 5, 2026 16:41
LTSM has a fixed 16 MiB heap and the manager kept the native key and channels of every group key it had ever unwrapped. A session that saw enough distinct group keys exhausted the heap and aborted with "ltsm: WASM abort called". Keep at most 4096 native group keys and channels, evicting the least recently used. Eviction destroys the native key and every channel created from it. The connector already fetches and unwraps a missing group key on demand, so an evicted key is reloaded the next time it is needed.
highesttt
force-pushed
the
highest/evict-group-keys
branch
from
October 5, 2026 16:55
451152c to
004cd1a
Compare
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.
LTSM has a fixed 16 MiB heap. A session still keeps the native key and channels of every group key it unwraps, and nothing ever destroys them. A session that sees enough distinct group keys exhausts the heap and aborts with
ltsm: WASM abort called.This keeps at most 4096 native group keys and channels (about 3 MB) and evicts the least recently used. Eviction destroys the native key and every channel created from it through the new
Runner.KeyDestroy. The connector already fetches and unwraps a missing group key on demand (fetchAndUnwrapGroupKeyon a decrypt miss and before every send), so an evicted key is reloaded the next time it is needed.DecryptGroupMessageandEncryptGroupMessageRawnow holdManager.mufrom the key lookup through the native call, so an eviction cannot destroy the channel they are using. Native calls already serialize on the runner's own mutex. The ZIP retry insendMessagenow refetches the group key and retries once, like the main send path, and surfaces refetch failures the same way, because a key can be evicted between the two sends.This relies on #252 (merged): before it, native unwrap leaked about 0.74 KB per call even after the key was destroyed, so eviction could not bound the heap.
#253 and #254 also change
RunnerandManager, so whichever of them and this lands second needs a small rebase. In particularKeyDestroyhas to follow #253's failure and discard handling.Testing
Local, synthetic keys and messages only. No tests are added to the diff; the checks below ran outside the repo through a Go overlay. Each loop iteration unwraps a group key, then encrypts and decrypts a message and checks the plaintext.
go test ./pkg/...andgo test -race ./pkg/e2ee ./pkg/connector/...pass. A separate stress run with the cap lowered to 6 has four goroutines unwrap, encrypt and decrypt while keys are evicted. It sees only "key not loaded" or "not found" errors, passes three times under-race, and fails withunknown channelagainst a version ofmanager.gothat released the lock before the native call.Limits
Manager.mufor the duration of the native call, so otherManagermethods wait behind them.