runtime: implement weak.runtime_makeStrongFromWeak - #5633
Open
yohimik wants to merge 1 commit into
Open
Conversation
This was referenced Aug 30, 2026
The runtime had weak.runtime_registerWeakPointer but not its counterpart, so a program that reads a weak pointer back did not link. crypto/tls does this in the certificate cache that it keeps behind a weak.Pointer. Weak pointers are not weak here. registerWeakPointer returns the pointer that it got, so the value it refers to stays and the way back to a strong pointer is the identity too. weak.Pointer.Value thus never reports a collected value, which the documented contract permits. testdata/weak.go does not link on the current dev branch and prints the expected value with this change.
yohimik
force-pushed
the
upstream-pr/weak-strong-from-weak
branch
from
September 2, 2026 08:50
1388449 to
931c476
Compare
Author
|
Rebased on dev after the 0.42.0 release. The change applies on top of v0.42.0 |
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.
runtime: implement weak.runtime_makeStrongFromWeak
What this does
The runtime has
weak.runtime_registerWeakPointerbut not its counterpart, so aprogram that reads a weak pointer back does not link. The missing function is 7
lines.
Weak pointers are not weak here.
registerWeakPointerreturns the pointer thatit got, so the value it refers to stays and the way back to a strong pointer is
the identity too.
weak.Pointer.Valuethus never reports a collected value,which the documented contract permits.
Evidence
testdata/weak.gomakes a weak pointer and reads it back. It is registered inTestBuildunder theminor >= 24gate, because theweakpackage came withGo 1.24.
Measured on macOS 26.6 arm64.
weak/pointer.go:89: linker could not find symbol _weak.runtime_makeStrongFromWeakweak value: 42The program also builds for
cortex-m-qemu,riscv-qemuandsimavr.A downstream product also ships binaries built with a fork that carries this
change, in the published release dispat v1.4.0.
https://github.com/yohimik/dispat/releases/tag/services%2Fdispat%2Fv1.4.0
Why it matters
crypto/tlsusesweak.Pointerfor its certificate cache, so this is aprerequisite for the standard library
crypto/tlson any target. Any userprogram that uses
weakhits the same link error today.Scope
src/runtime/runtime.go. No API change, no behaviourchange for a program that does not use
weak.Related pull requests
This change is part of one body of work. Together the changes make programs that use the network and child processes work on hosted linux and macOS. A full CLI was tested end to end with all of them and ships binaries built this way, see dispat v1.4.0 in the evidence section.
In this repository
In tinygo-org/net
A merge order that works. The three bug fixes are independent. #5633 goes before #5635. HTTPS on linux needs only #5633 and #5635. Full darwin support also needs #5636, the net changes and a new src/net submodule pin.