Skip to contentSkip to conversation

depexp.py: Fix segfault if DISPLAY is not set

PATCH Superseded Maxin B. John 2 participants 3 messages Feb 9, 2015

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 depexp.py: Fix segfault if DISPLAY is not set

bitbake -g -u depexp <package> segfaults when DISPLAY is not set properly. Fix it with a proper check.

[YOCTO #7299]

---
 bitbake/lib/bb/ui/depexp.py | 7 +++++++
 1 file changed, 7 insertions(+)
bitbake/lib/bb/ui/depexp.py +7 -0
index 0c71a3e..9f1701f 100644
@@ -17,6 +17,7 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
+import sys
 import gobject
 import gtk
 import Queue
@@ -215,6 +216,12 @@ def main(server, eventHandler, params):
         print("XMLRPC Fault getting commandline:\n %s" % x)
         return
 
+    try:
+        gtk.init_check()
+    except:
+        print "Please set DISPLAY variable before running this command."
+        sys.exit(1)
+
     shutdown = 0
 
     gtkgui = gtkthread(shutdown)
Signature · 1 line
1.9.1
#1 lore raw

bitbake/lib/bb/ui/depexp.py def main(server, eventHandler, params): · line 224

Quoted 7 lines · Maxin B. John
bitbake/lib/bb/ui/depexp.py +6 -0
+    try:
+        gtk.init_check()
+    except:
+        print "Please set DISPLAY variable before running this command."
+        sys.exit(1)
+

It's good that you're fixing this, but 1) this uses the old style non-function print, which isn't supported in new python, and 2) it outputs the error message to stdout rather than stderr, and 3) it looks like just returning rather than exiting is likely the best move.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#2 lore raw

Hi,

Quoted 11 lines · Christopher Larson

On Mon, Feb 9, 2015 at 4:37 AM, Maxin B. John <[email protected]> wrote:

+ try:
+ gtk.init_check()
+ except:
+ print "Please set DISPLAY variable before running this command."
+ sys.exit(1)
+

Quoted 4 lines

It's good that you're fixing this, but 1) this uses the old style non-function print, which isn't supported in new python, and 2) it outputs the error message to stdout rather than stderr, and 3) it looks like just returning rather than exiting is likely the best move.

Thank you very much for the review comments. I will update it as per your suggestions and send the v2 soon.

Quoted 5 lines

Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics

Thanks and Regards,
Maxin