Skip to content

runtime: implement weak.runtime_makeStrongFromWeak - #5698

Draft
yohimik wants to merge 1 commit into
tinygo-org:devfrom
yohimik:upstream-pr/weak-strong-from-weak
Draft

yohimik wants to merge 1 commit into
tinygo-org:devfrom
yohimik:upstream-pr/weak-strong-from-weak

Conversation

@yohimik

@yohimik yohimik commented Sep 17, 2026

Copy link
Copy Markdown

Addresses #5693. Programs that call weak.Pointer.Value() fail to link. Add the missing runtime hook and a test that reads a live value.

The hook matches the existing pointer registration behavior. It does not add weak pointer collection. Hosted TLS in #5700 needs this hook.

Replaces #5633, closed on 17 September 2026 with a request for an issue first. Based on dev at 93940cb6. Patches are unchanged after rebase. Formatting and whitespace checks pass. New runtime tests and CI are pending.

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.
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