Fix NativeStringContext: fixed 8MB pool, malloc fallback, and proper free - #1264
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/uNetworking/uWebSockets.js/sessions/32b57b77-b272-4971-920c-090468456f40 Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add NativeStringContext::free to manage memory pointers
Fix NativeStringContext: fixed 8MB pool, malloc fallback, and proper free
Mar 29, 2026
uNetworkingAB
marked this pull request as ready for review
March 29, 2026 20:15
uNetworkingAB
added a commit
that referenced
this pull request
Apr 2, 2026
* Revert "Fix NativeStringContext: fixed 8MB pool, malloc fallback, and proper free (#1264)" This reverts commit 71cac73. Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com> * Revert "Replace NativeString heap allocations with thread-local pool allocator (#1263)" This reverts commit 3e2ea85. Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com> * Revert "Update NativeString to use better copy mechanism and ValueView for utf8 string data direct access (#1262)" This reverts commit 6b4968f. Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com> * Revert "Add DataView support, update RecognizedString type (#1258)" This reverts commit 0b0c8f9. Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com>
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.
The pool in
NativeStringContextcouldresize()(reallocate), leaving dangling pointers in any liveNativeString. Additionally, no mechanism existed to release dynamically allocated memory.Changes
alloc()no longer callsresize(). This prevents vector reallocation from invalidating pointers held byNativeString.alloc()falls back tomalloc()instead of growing the pool.NativeStringContext::free(char *): Checks if pointer is within pool range — no-op if so, calls::free()otherwise. This correctly handles both the pool and malloc'd cases with a single call.NativeStringdestructor: Tracks anallocatedflag (set only on the UTF-8 string copy path) and callsctx->free(data)on destruction. Copy constructor and assignment operator are deleted to prevent double-free.📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.