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

Copy structs when native code has ownership #124

Closed
jwharm opened this issue Aug 31, 2024 · 0 comments
Closed

Copy structs when native code has ownership #124

jwharm opened this issue Aug 31, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jwharm
Copy link
Owner

jwharm commented Aug 31, 2024

When native code returns a struct or boxed type with transfer-ownership="none", the struct should be copied. For boxed types, use g_boxed_copy; for other types, either use the copy-func annotation (often missing) or heuristics (look for a copy or ref function), and register it with the MemoryCleaner so the copy will be disposed later.

Without this, the struct can be disposed somewhere else and when Java code then tries to use it, the program will segfault.

@jwharm jwharm added the bug Something isn't working label Aug 31, 2024
@jwharm jwharm closed this as completed in 0ca67b4 Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant