StyleContext.lookupColor causes GSlice MemChecker to fail #221
I'm working on resolving some crash issues in Tilix (gnunn1/tilix#1192). Running tilix with
Looking at the code for lookupColor, I can see that memory is being allocated for the RGBA so GtkD should own it, I'm not seeing why it has already been released? Note that most of the RGBA instances I am using are throwaway in the sense they can used in a method and go out of scope as soon as the method completes. The error occurs when the D GC is invoked.
If you want to reproduce it with tilix:
Once tilix is running, open the preference dialog and close it. If it doesn't happen, go into the hamburger menu and select GC to force a garbage collection cycle.
Here is the stack trace.
GSlice: MemChecker: attempt to release non-allocated block: 0x555557076510 size=32
Thread 1 "tilix" received signal SIGABRT, Aborted.
The text was updated successfully, but these errors were encountered:
Most of the time the time the C side uses the slice allocator, and the free functions will in that case call g_slice_free and that fails if the memory wasn't used to allocate the memory. See Also: #221
Using your updated code I no longer have the GSlice: MemChecker issue however I've noticed a new problem with this change. I have a patched VTE that when detected calls some additional code which in turn calls the
Here is where I call the method:
BTW, I realize I don't need to create the attributes object and I'll fix that however it makes no difference for this issue.
I have pasted the stack trace below.
Not as far as i can tell, using malloc we would have the same bug only without the segfault which isn't a good option.
GtkD never frees the GArray (which should be looked into) which is why there is no error when using malloc, the segfault is triggered when getTextRange tries to read/write past the allocated memory.
We either need to add some padding bytes to the struct definitions in GtkD, or special case the GArray types in the generator to use _new.