Activating Action causes SIGSEGV #298
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
java
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
java-gi/java-gi#298
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I have two Actions defined like so:
If I want to call the
play-albumaction I get a SIGSEGVIt's called like so:
However, if I call my
queue-albumaction, this doesn't happen.Logging confirms, that the activation handler isn't even being called.
Based on the example code, I don't see any reason why "queue-album" would work and "play-album" wouldn't.
I created a simple application with two ActionEntries, and I can activate them without issues. Are you sure that the action entries added to the window and not to the application?
Can you remove the
exec.submit()calls just to be completely sure that this isn't a concurrency issue?For example, would this work?
I am adding them to the window.
I rewrote the code to use the proper
VariantTypes.STRINGand got rid of the list.
Now every action triggers a SIGSEGV.
Ignore that I am now directly calling the
addActionEntriesonwin. I moved thecode to a different widget.
If I simply create
SimpleActioninstances and add them directly, it works without issues.It crashes here:
I don't know whether it is relevant, but the debugger says that args is of type Variant with length 0.
Thanks for the additional info. However, I still cannot reproduce the segfault. Can you please provide a complete program that I can run? If that's not feasible, then maybe the stack trace that leads to the
gtk_widget_activate_action_variantwill be helpful, because I have no idea where it's invoked.Thanks for your help.
I finally got around to putting the code on GitHub.
However, while you could run it, it requires a user on a Navidrome instance to function.
But at least the full code can be inspected.
The following links point to the relevant section:
github.com/Nyeksenn/GrooveBoat@59ac174549/src/main/java/io/github/Nyeksenn/grooveboat/ui/MusicPlayer.java (L213)github.com/Nyeksenn/GrooveBoat@59ac174549/src/main/java/io/github/Nyeksenn/grooveboat/ui/SongCard.java (L61)This is the stacktrace:
stacktrace.txt
Perhaps the
argparameter is disposed too soon.When you add
arg.ref();directly after this line, does the crash still happen?I tried you proposal but sadly it didn't work.
The stack trace remains the same.
Then perhaps the action entries are disposed too soon.
In the MusicPlayer class, when creating the action entries, specify the global arena so they will stay alive.
So when creating the ActionEntry:
add an extra parameter:
for all 4 entries.
ActionEntry is a simple C struct, and when you create one, Java-GI allocates memory for it. This is done with an arena. If you don't specifiy a specific arena, then by default
Arena.ofAuto()is used. That arena disposes all allocated memory when the Java MemorySegment is garbage-collected. The MemorySegment is an instance field in the entries. But the entries are eligible for GC after thesetupActions()method returns.That fixed it. Thank you so much :)