Seg fault on closing the xpad

Bug #1333727 reported by Sagar Ghuge
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Xpad
Fix Released
Low
Sagar Ghuge

Bug Description

Steps to produce the bug :

1. launch xpad
2. try to close xpad

It will gets closed by throwing seg fault.

Related branches

Revision history for this message
Arthur Borsboom (arthurborsboom) wrote :

Hi Sagar,

Thanks for looking into this and supplying a possible fix.
I haven't tested it, but I do have some questions.

Since the destroy function has been run before, the group->priv->pads object should be destroyed and therefore this unref seems to me not necessary and will never be called, since group->priv->pads is not an object anymore. Would you mind to verify if this added piece of code, will ever be called? Besides that, it is a good habit too set a variable to NULL when not used anymore.

- group->priv->pads = NULL;
+
+ if (G_IS_OBJECT (group->priv->pads))
+ {
+ g_object_unref (group->priv->pads);
+ }

Also by removing the code below, I guess that you introduce a memory leak on application exit. You can verify this with the application gobject-list (https://github.com/danni/gobject-list). On application exit, there should be no references to 'xpad' objects anymore. The command line I use for this is:

LD_PRELOAD=~/home/development/gojbect-list/libgobject-list.so src/xpad | grep xpad

- /* Free the memory used by group. */
- if (G_IS_OBJECT (pad_group))
- g_object_unref (pad_group);
-

My guess of the cause of the segmentation fault is a timing issue (race condition), between different threads while destroying the different objects. However, I don't have a solution for this problem yet.

Can you verify that
- the g_object_unref (group->priv->pads) is ever called?
- there are no memory leaks of xpad objects?

Cheers,
Arthur.

Revision history for this message
Arthur Borsboom (arthurborsboom) wrote :

In fact this is the command I use to verify memory leaks of Xpad objects:

LD_PRELOAD=~/Development/tools/gobject-list/libgobject-list.so src/xpad | grep xpad -i

And this is the result, I of Xpad 4.3 in the main branch, when I start and immediately quit the application.

 ++ Created object 0xff0af0, XpadSettings
 ++ Created object 0xfed440, XpadPadGroup
 ++ Created object 0x1055660, XpadUndo
 ++ Created object 0xf72ba0, XpadTextBuffer
 ++ Created object 0x10f8260, XpadTextView
 ++ Created object 0x112c7e0, XpadGripToolItem
 ++ Created object 0x11271d0, XpadToolbar
 ++ Created object 0x10f6450, XpadPad
 ++ Created object 0x111b1e0, XpadUndo
 ++ Created object 0x7f8b240076d0, XpadTextBuffer
 ++ Created object 0x10f8500, XpadTextView
 ++ Created object 0x1154f40, XpadGripToolItem
 ++ Created object 0x1173170, XpadToolbar
 ++ Created object 0x10f6740, XpadPad
 -- Finalized object 0x112c7e0, XpadGripToolItem
 -- Finalized object 0x11271d0, XpadToolbar
 -- Finalized object 0x10f8260, XpadTextView
 -- Finalized object 0x1055660, XpadUndo
 -- Finalized object 0xf72ba0, XpadTextBuffer
 -- Finalized object 0x10f6450, XpadPad
 -- Finalized object 0x1154f40, XpadGripToolItem
 -- Finalized object 0x1173170, XpadToolbar
 -- Finalized object 0x10f8500, XpadTextView
 -- Finalized object 0x111b1e0, XpadUndo
 -- Finalized object 0x7f8b240076d0, XpadTextBuffer
 -- Finalized object 0x10f6740, XpadPad
 -- Finalized object 0xfed440, XpadPadGroup
 -- Finalized object 0xff0af0, XpadSettings
[arthur@AOD270 xpad]$

Changed in xpad:
status: New → Confirmed
milestone: none → 4.4
Revision history for this message
Arthur Borsboom (arthurborsboom) wrote :

Okay, I couldn't resist. I just checked an indeed, this does introduce a memory leak.
After the patch, this is the result.

[arthur@AOD270 xpad-4.4]$ LD_PRELOAD=~/Development/tools/gobject-list/libgobject-list.so src/xpad | grep xpad -i
 ++ Created object 0x16c72f0, XpadSettings
 ++ Created object 0x1657e40, XpadPadGroup
 ++ Created object 0x172aa60, XpadUndo
 ++ Created object 0x1649ba0, XpadTextBuffer
 ++ Created object 0x17ce260, XpadTextView
 ++ Created object 0x18037e0, XpadGripToolItem
 ++ Created object 0x17fe1d0, XpadToolbar
 ++ Created object 0x17cc450, XpadPad
 ++ Created object 0x17f21e0, XpadUndo
 ++ Created object 0x7f53980076d0, XpadTextBuffer
 ++ Created object 0x17ce500, XpadTextView
 ++ Created object 0x182af40, XpadGripToolItem
 ++ Created object 0x1849170, XpadToolbar
 ++ Created object 0x17cc740, XpadPad
 -- Finalized object 0x18037e0, XpadGripToolItem
 -- Finalized object 0x17fe1d0, XpadToolbar
 -- Finalized object 0x17ce260, XpadTextView
 -- Finalized object 0x172aa60, XpadUndo
 -- Finalized object 0x1649ba0, XpadTextBuffer
 -- Finalized object 0x17cc450, XpadPad
 -- Finalized object 0x182af40, XpadGripToolItem
 -- Finalized object 0x1849170, XpadToolbar
 -- Finalized object 0x17ce500, XpadTextView
 -- Finalized object 0x17f21e0, XpadUndo
 -- Finalized object 0x7f53980076d0, XpadTextBuffer
 -- Finalized object 0x17cc740, XpadPad
 -- Finalized object 0x16c72f0, XpadSettings
 - 0x1657e40, XpadPadGroup: 1 refs
[arthur@AOD270 xpad-4.4]$

Sagar Ghuge (ghugesss)
Changed in xpad:
assignee: nobody → Sagar Ghuge (ghugesss)
Changed in xpad:
importance: Undecided → Low
status: Confirmed → Fix Committed
Changed in xpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.