Ticket #7486 (closed defect: fixed)

Opened 4 months ago

Last modified 2 months ago

Sugar shell crashes when threads used.

Reported by: cscott Owned by: tomeu
Priority: high Milestone: 8.2.0 (was Update.2)
Component: sugar Version: Development build as of this date
Keywords: joyride-2268:+ sugar-0.82.0:+ Cc: marco, tomeu, cjb
Action Needed: finalize Verified: no
Deployments affected: Blocked By:
Blocking:

Description

Sugar never calls gtk.gdk.threads_init(), so any attempt to use threads in code called by the sugar shell (control panel code in particular) causes sugar to crash -- python throws an assertion about its GILlock.

The fix is very simple: in /usr/share/sugar/shell/main.py, right after:

pygtk.require('2.0')
import gtk
import gobject

add the line:

gtk.gdk.threads_init()

Voila! No more crashes.

Found this bug while writing the 'activity update' sugar control panel, which uses threads to keep the UI responsive while it is doing network operations in the background to update activity version status.

Attachments

Change History

follow-up: ↓ 2   Changed 4 months ago by mstone

  • cc marco, tomeu added
  • keywords 8.2.0:? added
  • next_action changed from never set to communicate

Was Sugar _intentionally_ not calling threads_init()?

in reply to: ↑ 1   Changed 4 months ago by marco

Replying to mstone:

Was Sugar _intentionally_ not calling threads_init()?

Well, you usually call threads_init when you are using threads, and the sugar shell has not been using them so far. I guess the cp panel Scott is talking about is not part of sugar yet?

  Changed 4 months ago by cscott

No one can call threads_init after sugar starts, so if anyone installs a control panel which needs threads (which I do), sugar needs to properly init the threads at the start.

The control panel deliberately has a modular design which lets people slot in external control panels. Sugar should support their use of threads.

  Changed 4 months ago by tomeu

We actively eliminated use of threads in sugar because it used to cause pygtk to wake up 10 times per second. I think that both fedora and ubuntu have applied a patch about that to both python and pygtk, so I think we can add it back. We should test again if we are causing unnecessary wakeups that may interfere with battery conservation.

Changed 4 months ago by tomeu

  Changed 4 months ago by tomeu

  • keywords r? added
  • owner changed from marco to tomeu
  • next_action changed from communicate to review

  Changed 4 months ago by tomeu

|TestCase|

In a build generated by a pilgrim version without the fix linked below, check that Sugar starts up correctly.

http://dev.laptop.org/git?p=users/cscott/pilgrim;a=commitdiff;h=205c907270a07836f29709cf1d13257d56d4a846

(please improve this test case)

  Changed 4 months ago by cscott

  • cc cjb added

If you can tell me when sugar packages with this patch will show up in joyride (either temporarily via the public_rpms mechanism or via koji), I can have the pilgrim patch removed.

cjb, as our resident power guru, could you double check that pygtk in current joyride builds (which have a patch to enable threads) isn't causing excessive wakeups?

  Changed 4 months ago by erikos

  • keywords r+ added; r? removed

Ok we will add it to the next build and will tell you when to remove from pilgrim. A test from cjb about wakeups would be nice indeed.

  Changed 4 months ago by marco

  • next_action changed from review to add to build

  Changed 4 months ago by marco

  • next_action changed from add to build to package

  Changed 4 months ago by marco

  • keywords 8.2.0:+ joyride-2220:+ added; 8.2.0:? removed
  • next_action changed from package to finalize

  Changed 4 months ago by erikos

  • next_action changed from finalize to package

  Changed 3 months ago by erikos

  • keywords joyride-2268:+ sugar-0.82.0:+ added; 8.2.0:+ joyride-2220:+ r+ removed
  • next_action changed from package to finalize

The pilgrim patch has been removed and the control panel starts up fine in joyride >= 2268

  Changed 2 months ago by gregorio

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.