Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Preserve GValues from GC (fixes #581) (#600)
Browse files Browse the repository at this point in the history
As a consequence of the forced specialization on the `RT` argument
of `signal_emit` in #552, the compiler now knows whether
`RT === Nothing`. In that case, it also knows that
`return_value` will not be used, so it is free to be garbage-collected.
When that happens, it triggers segfaults.

This puts both potential `GValue`-arguments inside a `GC.@preserve`
to prevent garbage collection. Fixes #581.
  • Loading branch information
timholy authored Dec 6, 2021
1 parent fc3a648 commit d28f725
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Gtk"
uuid = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44"
version = "1.1.9"
version = "1.1.10"

[deps]
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
Expand Down
3 changes: 2 additions & 1 deletion src/GLib/signals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ function signal_emit(w::GObject, sig::AbstractStringLike, ::Type{RT}, args...) w
end
signal_id = ccall((:g_signal_lookup, libgobject), Cuint, (Ptr{UInt8}, Csize_t), sig, G_OBJECT_CLASS_TYPE(w))
return_value = RT === Nothing ? C_NULL : gvalue(RT)
ccall((:g_signal_emitv, libgobject), Nothing, (Ptr{GValue}, Cuint, UInt32, Ptr{GValue}), gvalues(w, args...), signal_id, detail, return_value)
gvals = gvalues(w, args...)
GC.@preserve gvals return_value ccall((:g_signal_emitv, libgobject), Nothing, (Ptr{GValue}, Cuint, UInt32, Ptr{GValue}), gvals, signal_id, detail, return_value)
RT === Nothing ? nothing : return_value[RT]
end

Expand Down

2 comments on commit d28f725

@timholy
Copy link
Member Author

@timholy timholy commented on d28f725 Dec 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/50052

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.10 -m "<description of version>" d28f725796675d2bb0bb0f68195959fb8b489338
git push origin v1.1.10

Please sign in to comment.