Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why go4.org/unsafe/assume-no-moving-gc ? #101

Open
s3rj1k opened this issue Mar 29, 2023 · 4 comments
Open

Why go4.org/unsafe/assume-no-moving-gc ? #101

s3rj1k opened this issue Mar 29, 2023 · 4 comments

Comments

@s3rj1k
Copy link

s3rj1k commented Mar 29, 2023

Just out of curiosity why go4.org/unsafe/assume-no-moving-gc is needed and can it be removed at some point?

@diamondburned
Copy link
Owner

It's needed because package core/intern requires some uintptr hacks to replicate weak references, which was needed to prevent certain memory leaks from occuring. This assumes that the GC doesn't move pointers around when they're on the heap, which the package acts as a safe guard for.

If something like golang/go#46787 gets added, we can probably get rid of assume-no-moving-gc altogether.

(As a side note, I'm not too confident that core/intern is doing its intended job right now. I'll have to look into it, but I think there was a regression that caused it to leak memory again. It's hard to figure this out when building the code after the slightest changes takes 20 minutes.)

@s3rj1k
Copy link
Author

s3rj1k commented Mar 29, 2023

Thanks for explaining, a bit hesitated to use the binding with that dependency

@s3rj1k
Copy link
Author

s3rj1k commented Mar 29, 2023

It's pretty much safe to close this issue, I would ask for a tagged release when gtk4 binding removes that unsafe dependency.

Thanks for your effort.

@jclc
Copy link

jclc commented Aug 9, 2023

@diamondburned Go 1.21 was released today and it has a new type runtime.Pinner for this purpose. Maybe worth taking a look?

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

No branches or pull requests

3 participants