ROOT-enabled Qt app hangs when loading ROOT?

Hi,

I’m a ROOT 5.13.05 user in Debian etch.
I’m working on a Qt application which at some point loads a plugin which itself uses a TQtWidget to render TH1-inheriting objects. (Therefore, ROOT is not started immediately.) “At some point” here means it opens a QWidget window with the embedded TQtWidget when the user double-clicks a QTable cell which contains a blob corresponding to the TObject, in order to open a QWidget with the embedded TQtWidget used to Draw the object.

It works well, except for a detail I still haven’t figured out. If I invoke the application without forking it in the console,

it works well. (BTW, is there a way to suppress the console logo output as well as other ROOT-based console output?)
However, if I fork the application in the console,

the application stops responding until I bring it to foreground in the console,

[1]+ Stopped myapp jbatista@localhost:~ fg
and then the Qt GUI starts responding again. It doesn’t matter if I set Gui.Prompt to true or false (is it relevant? I suspect not…), e.g.

Maybe this behavior is documented elsewhere? If so, please tell me where can I find it. If not, could someone please provide an explanation/hint?

The hanging seems to happen where I create the new TQtWidget.

This line I’ve inserted in the constructor of the window class that has the TQtWidget embedded.

Thank you in advance. :slight_smile:

[quote=“jbatista”]
It works well, except for a detail I still haven’t figured out. If I invoke the application without forking it in the console,

jbatista@localhost:~ ./myapp 

it works well. (BTW, is there a way to suppress the console logo output as well as other ROOT-based console output?)[/quote]
The simplest way

yourapplication >&/dev/null :wink:

[quote=“jbatista”]
However, if I fork the application in the console,

jbatista@localhost:~ ./myapp & 

the application stops responding until I bring it to foreground in the console, . . .[/quote]
Hello,
What you did is correct and it should work as you expect.
To go further I have to be able to reproduce your problem.
Would you mind to download and install “ex1” example from “HelloWord example” kits.

root.bnl.gov/QtRoot/downloads/qt … les.tar.gz
root.bnl.gov/QtRoot/README_Hello_Example
root.bnl.gov/QtRoot/QtRoot.html#helloroot

Please check whether you can “fork” it.

[quote=“jbatista”]
It doesn’t matter if I set Gui.Prompt to true or false (is it relevant? I suspect not…),
[/quote]This is correct :wink: There should be no connection between the “Root Prompt” and your observation. By default, Gui.Prompt is “false” for the ROOT-based Qt applications

[quote=“jbatista”]Maybe this behavior is documented elsewhere? If so, please tell me where can I find it. If not, could someone please provide an explanation/hint?[/quote]I have no explanation yet :unamused:
Can you attach the gdb debugger to your hanged process to see where it is looping in. To do that, “fork” your application, then start “gdb -p ” where is your process PID. Please, send me any call stack the debugger may have produced.[quote=“jbatista”]
The hanging seems to happen where I create the new TQtWidget.

rootwidget = new TQtWidget(this,"rootwidget");

This line I’ve inserted in the constructor of the window class that has the TQtWidget embedded.[/quote]

Please do 3 things:

  1. Install “Examples”
  2. Attach “gdb” to your process
  3. Send me the result.

You are welcome

Hi,

[quote=“fine”]Would you mind to download and install “ex1” example from “HelloWord example” kits.

root.bnl.gov/QtRoot/downloads/qt … les.tar.gz
root.bnl.gov/QtRoot/README_Hello_Example
root.bnl.gov/QtRoot/QtRoot.html#helloroot

Please check whether you can “fork” it.[/quote]

Well, I downloaded, compiled and tested “ex1”. It did work as expected, ran with no problems. :slight_smile:

This is the output from a console where I ran gdb:

[code]Script started on Thu Dec 7 16:40:59 2006
jbatista@jblap:~$ ps a
PID TTY STAT TIME COMMAND
2056 tty7 Ss+ 7:41 /usr/X11R6/bin/X :0 -dpi 84 -audit 0 -auth /var/lib/gdm/:0.Xauth -nolisten tcp vt7
2088 tty1 Ss+ 0:00 /sbin/getty 38400 tty1
2089 tty2 Ss+ 0:00 /sbin/getty 38400 tty2
2090 tty3 Ss+ 0:00 /sbin/getty 38400 tty3
2091 tty4 Ss+ 0:00 /sbin/getty 38400 tty4
2092 tty5 Ss+ 0:00 /sbin/getty 38400 tty5
2093 tty6 Ss+ 0:00 /sbin/getty 38400 tty6
7249 pts/1 Ss+ 0:00 bash
7317 pts/1 S 0:00 /bin/sh /usr/bin/mysqld_safe
7354 pts/1 Sl 0:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mys
7355 pts/1 S 0:00 logger -p daemon.err -t mysqld_safe -i -t mysqld
19742 pts/0 Ss 0:00 bash
19749 pts/3 Ss+ 0:00 bash
19793 pts/0 S+ 0:00 script run3.txt
19794 pts/0 S+ 0:00 script run3.txt
19795 pts/4 Ss 0:00 bash -i
19812 pts/3 S 0:00 src/ktidbexplorer
19815 pts/4 R+ 0:00 ps a
jbatista@jblap:~$ gdb -p 19812
GNU gdb 6.5-debian
Copyright © 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “i486-linux-gnu”.
Attaching to process 19812
Reading symbols from /home/jbatista/software/TIDB2/atlas06/tidb2/ktidbexplorer/src/ktidbexplorer…done.
Using host libthread_db library “/lib/tls/libthread_db.so.1”.
Reading symbols from /usr/lib/libkio.so.4…done.
Loaded symbols for /usr/lib/libkio.so.4
Reading symbols from /usr/lib/libkdesu.so.4…done.
Loaded symbols for /usr/lib/libkdesu.so.4
Reading symbols from /usr/lib/libkwalletclient.so.1…done.
Loaded symbols for /usr/lib/libkwalletclient.so.1
Reading symbols from /usr/lib/libfam.so.0…done.
Loaded symbols for /usr/lib/libfam.so.0
Reading symbols from /lib/libacl.so.1…done.
Loaded symbols for /lib/libacl.so.1
Reading symbols from /lib/libattr.so.1…done.
Loaded symbols for /lib/libattr.so.1
Reading symbols from /usr/lib/libkdeui.so.4…done.
Loaded symbols for /usr/lib/libkdeui.so.4
Reading symbols from /usr/lib/libkdecore.so.4…done.
Loaded symbols for /usr/lib/libkdecore.so.4
Reading symbols from /usr/lib/libDCOP.so.4…done.
Loaded symbols for /usr/lib/libDCOP.so.4
Reading symbols from /lib/tls/libresolv.so.2…done.
Loaded symbols for /lib/tls/libresolv.so.2
Reading symbols from /lib/tls/libutil.so.1…done.
Loaded symbols for /lib/tls/libutil.so.1
Reading symbols from /usr/lib/libart_lgpl_2.so.2…done.
Loaded symbols for /usr/lib/libart_lgpl_2.so.2
Reading symbols from /usr/lib/libidn.so.11…done.
Loaded symbols for /usr/lib/libidn.so.11
Reading symbols from /usr/lib/libkdefx.so.4…done.
Loaded symbols for /usr/lib/libkdefx.so.4
Reading symbols from /usr/lib/libqt-mt.so.3…done.
Loaded symbols for /usr/lib/libqt-mt.so.3
Reading symbols from /usr/lib/libaudio.so.2…done.
Loaded symbols for /usr/lib/libaudio.so.2
Reading symbols from /usr/lib/libXt.so.6…done.
Loaded symbols for /usr/lib/libXt.so.6
Reading symbols from /usr/lib/libjpeg.so.62…done.
Loaded symbols for /usr/lib/libjpeg.so.62
Reading symbols from /usr/lib/libXi.so.6…done.
Loaded symbols for /usr/lib/libXi.so.6
Reading symbols from /usr/lib/libXrandr.so.2…done.
Loaded symbols for /usr/lib/libXrandr.so.2
Reading symbols from /usr/lib/libXcursor.so.1…done.
Loaded symbols for /usr/lib/libXcursor.so.1
Reading symbols from /usr/lib/libXinerama.so.1…done.
Loaded symbols for /usr/lib/libXinerama.so.1
Reading symbols from /usr/lib/libXft.so.2…done.
Loaded symbols for /usr/lib/libXft.so.2
Reading symbols from /usr/lib/libfreetype.so.6…done.
Loaded symbols for /usr/lib/libfreetype.so.6
Reading symbols from /usr/lib/libfontconfig.so.1…done.
Loaded symbols for /usr/lib/libfontconfig.so.1
Reading symbols from /usr/lib/libpng12.so.0…done.
Loaded symbols for /usr/lib/libpng12.so.0
Reading symbols from /usr/lib/libXext.so.6…done.
Loaded symbols for /usr/lib/libXext.so.6
Reading symbols from /usr/lib/libX11.so.6…done.
Loaded symbols for /usr/lib/libX11.so.6
Reading symbols from /usr/lib/libSM.so.6…done.
Loaded symbols for /usr/lib/libSM.so.6
Reading symbols from /usr/lib/libICE.so.6…done.
Loaded symbols for /usr/lib/libICE.so.6
Reading symbols from /lib/tls/libpthread.so.0…done.
[Thread debugging using libthread_db enabled]
[New Thread -1233966720 (LWP 19812)]
Loaded symbols for /lib/tls/libpthread.so.0
Reading symbols from /usr/lib/libXrender.so.1…done.
Loaded symbols for /usr/lib/libXrender.so.1
Reading symbols from /home/jbatista/software/TIDB2/atlas06/tidb2/tidb2/debian/libtidb2/usr/lib/libtidb2.so.0…done.
Loaded symbols for /home/jbatista/software/TIDB2/atlas06/tidb2/tidb2/debian/libtidb2/usr//lib/libtidb2.so.0
Reading symbols from /usr/lib/libz.so.1…done.
Loaded symbols for /usr/lib/libz.so.1
Reading symbols from /lib/tls/libdl.so.2…done.
Loaded symbols for /lib/tls/libdl.so.2
Reading symbols from /usr/lib/i686/cmov/libssl.so.0.9.8…done.
Loaded symbols for /usr/lib/i686/cmov/libssl.so.0.9.8
Reading symbols from /usr/lib/i686/cmov/libcrypto.so.0.9.8…done.
Loaded symbols for /usr/lib/i686/cmov/libcrypto.so.0.9.8
Reading symbols from /usr/lib/libstdc++.so.6…done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/tls/libm.so.6…done.
Loaded symbols for /lib/tls/libm.so.6
Reading symbols from /lib/libgcc_s.so.1…done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/tls/libc.so.6…done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /usr/lib/libXfixes.so.3…done.
Loaded symbols for /usr/lib/libXfixes.so.3
Reading symbols from /usr/lib/libexpat.so.1…done.
Loaded symbols for /usr/lib/libexpat.so.1
Reading symbols from /usr/lib/libXau.so.6…done.
Loaded symbols for /usr/lib/libXau.so.6
Reading symbols from /usr/lib/libXdmcp.so.6…done.
Loaded symbols for /usr/lib/libXdmcp.so.6
Reading symbols from /lib/ld-linux.so.2…done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /usr/lib/kde3/plugins/styles/plastik.so…done.
Loaded symbols for /usr/lib/kde3/plugins/styles/plastik.so
Reading symbols from /usr/lib/qt3/plugins/imageformats/libqmng.so…done.
Loaded symbols for /usr/lib/qt3/plugins/imageformats/libqmng.so
Reading symbols from /usr/lib/libmng.so.1…done.
Loaded symbols for /usr/lib/libmng.so.1
Reading symbols from /usr/lib/liblcms.so.1…done.
Loaded symbols for /usr/lib/liblcms.so.1
Reading symbols from /usr/lib/tidb2Plugins/libtidb2mysql.so…done.
Loaded symbols for /usr/lib/tidb2Plugins/libtidb2mysql.so
Reading symbols from /usr/lib/libmysqlclient.so.15…done.
Loaded symbols for /usr/lib/libmysqlclient.so.15
Reading symbols from /lib/tls/libcrypt.so.1…done.
Loaded symbols for /lib/tls/libcrypt.so.1
Reading symbols from /lib/tls/libnsl.so.1…done.
Loaded symbols for /lib/tls/libnsl.so.1
Reading symbols from /lib/tls/libnss_files.so.2…done.
Loaded symbols for /lib/tls/libnss_files.so.2
0xb68265b8 in select () from /lib/tls/libc.so.6
(gdb) continue
Continuing.

Program received signal SIGTTOU, Stopped (tty output).
[Switching to Thread -1233966720 (LWP 19812)]
0xb6824fb9 in tcsetattr () from /lib/tls/libc.so.6
(gdb)
Continuing.

Program received signal SIGTTOU, Stopped (tty output).
0xb6824fb9 in tcsetattr () from /lib/tls/libc.so.6
(gdb) continue
Continuing.

Program exited normally.
(gdb) quit
jbatista@jblap:~$ exit
exit

Script done on Thu Dec 7 16:45:28 2006[/code]

Curiously, it seems that after running gdb, subsequent runs of the same program doesn’t cause the anomally… :open_mouth:

GREAT :smiley:

[quote=“jbatista”]This is the output from a console where I ran gdb:

[code]Script started on Thu Dec 7 16:40:59 2006

Reading symbols from /usr/lib/liblcms.so.1…done.
Loaded symbols for /usr/lib/liblcms.so.1
Reading symbols from /usr/lib/tidb2Plugins/libtidb2mysql.so…done.
Loaded symbols for /usr/lib/tidb2Plugins/libtidb2mysql.so
Reading symbols from /usr/lib/libmysqlclient.so.15…done.
Loaded symbols for /usr/lib/libmysqlclient.so.15
. . .

0xb68265b8 in select () from /lib/tls/libc.so.6
(gdb) continue
Continuing.
. . .
[/code]
[/quote]At this point I would like to see the “call stack”. You can produce it the “bt 20” gdb command (instead of your “continue”) .
Anyway . . .

I have some suspect :imp:
Pay your attention to the libraries :bulb:

Loaded symbols for /usr/lib/liblcms.so.1 Reading symbols from /usr/lib/tidb2Plugins/libtidb2mysql.so...done.
I am wondering if your application hang due the non-correct mask set to the “select” :smiling_imp: function invoked from your CMS MySQL code.
I suspect :blush: the mask contains the redundant terminal bit. As result the said select is awaiting the socket event as well as the terminal one. In addition I suspect that “culprit” has the unlimited timeout interval set (which is just zero).

This may explain your observation. To see whether my suspection has any ground I need to see the call stack that I mentioned above. I guess it should reveal the truth, namely, that your code sticks with the “select” within CMS MySQL query code and the QtRoot is innocent.

Can you check that ?

Perhaps I should have explained earlier, my experience with gdb is of the order of epsilon… :blush:

[quote=“fine”]This may explain your observation. To see whether my suspection has any ground I need to see the call stack that I mentioned above. I guess it should reveal the truth, namely, that your code sticks with the “select” within CMS MySQL query code and the QtRoot is innocent.

Can you check that ?[/quote]

Certainly. :slight_smile:

Anyway, here goes. Did the usual “gdb -p ”. I’ve excluded the “Reading symbols” messages for brevity.

code bt 20
#0 0xb67d15c8 in select () from /lib/tls/libc.so.6
#1 0xb6fef258 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3
#2 0xb7062129 in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3
#3 0xb7061f4a in QEventLoop::exec () from /usr/lib/libqt-mt.so.3
#4 0xb704976f in QApplication::exec () from /usr/lib/libqt-mt.so.3
#5 0x0805b851 in main (argc=696, argv=0x0) at main.cpp:95[/code]
Had to do a “continue” so that the program could react again…

code continue
Continuing.

Program received signal SIGTTOU, Stopped (tty output).
[Switching to Thread -1234319680 (LWP 6598)]
0xb67cffc9 in tcsetattr () from /lib/tls/libc.so.6
(gdb)
Continuing.

Program received signal SIGTTOU, Stopped (tty output).
0xb67cffc9 in tcsetattr () from /lib/tls/libc.so.6
[/code]

The program hangs at this point, as usual. In gdb, I got the following backtrace:

code bt 40
#0 0xb67cffc9 in tcsetattr () from /lib/tls/libc.so.6
#1 0xb5ae5132 in Gl_histinit () from /usr/lib/root/libCore.so.5.13
#2 0xb5ae534d in Getlinem () from /usr/lib/root/libCore.so.5.13
#3 0xb4886779 in TQtWidget::InitRint () from /usr/lib/root/libGQt.so.5.13
#4 0xb4887226 in TQtWidget::TQtWidget () from /usr/lib/root/libGQt.so.5.13
#5 0xb48e6ba6 in frmroot::frmroot ()
from /home/jbatista/ktidbexplorer/plugins/.libs/ktidbexplgroot.so
#6 0xb48e89b6 in KTIDBExplorerroot::show ()
from /home/jbatista/ktidbexplorer/plugins/.libs/ktidbexplgroot.so
#7 0x080755f6 in CTableWindow::doubleClicked (this=0x81bc608, row=0, col=3,
button=1, mousePos=@0xbf901538) at ctablewindow.cpp:262
#8 0x080760df in CTableWindow::qt_invoke (this=0x81bc608, _id=51,
_o=0xbf90144c) at moc_ctablewindow.cpp:167
#9 0xb70afcb3 in QObject::activate_signal () from /usr/lib/libqt-mt.so.3
#10 0xb7475650 in QTable::doubleClicked () from /usr/lib/libqt-mt.so.3
#11 0xb72f9f60 in QTable::contentsMouseDoubleClickEvent ()
from /usr/lib/libqt-mt.so.3
#12 0xb71e3cc1 in QScrollView::viewportMouseDoubleClickEvent ()
from /usr/lib/libqt-mt.so.3
#13 0xb71e5370 in QScrollView::eventFilter () from /usr/lib/libqt-mt.so.3
#14 0xb72f9be8 in QTable::eventFilter () from /usr/lib/libqt-mt.so.3
#15 0xb70af266 in QObject::activate_filters () from /usr/lib/libqt-mt.so.3
#16 0xb70af2e4 in QObject::event () from /usr/lib/libqt-mt.so.3
—Type to continue, or q to quit—
#17 0xb70e6576 in QWidget::event () from /usr/lib/libqt-mt.so.3
#18 0xb7047bd6 in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3
#19 0xb7049d79 in QApplication::notify () from /usr/lib/libqt-mt.so.3
#20 0xb77f8e0e in KApplication::notify () from /usr/lib/libkdecore.so.4
#21 0xb6fdb445 in QApplication::sendSpontaneousEvent ()
from /usr/lib/libqt-mt.so.3
#22 0xb6fda0df in QETWidget::translateMouseEvent () from /usr/lib/libqt-mt.so.3
#23 0xb6fd8660 in QApplication::x11ProcessEvent () from /usr/lib/libqt-mt.so.3
#24 0xb6feecb2 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3
#25 0xb7062129 in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3
#26 0xb7061f4a in QEventLoop::exec () from /usr/lib/libqt-mt.so.3
#27 0xb704976f in QApplication::exec () from /usr/lib/libqt-mt.so.3
#28 0x0805b851 in main (argc=Cannot access memory at address 0x5402
) at main.cpp:95
(gdb)[/code]
At this point, a “continue” in gdb has no effect on the application, unless I go back to the app’s console and issue a “fg” to bring it back to foreground. Then, a “continue” in gdb resumes the app.

[quote=“fine”]I am wondering if your application hang due the non-correct mask set to the “select” :smiling_imp: function invoked from your CMS MySQL code.
I suspect :blush: the mask contains the redundant terminal bit. As result the said select is awaiting the socket event as well as the terminal one. In addition I suspect that “culprit” has the unlimited timeout interval set (which is just zero).

This may explain your observation. To see whether my suspection has any ground I need to see the call stack that I mentioned above. I guess it should reveal the truth, namely, that your code sticks with the “select” within CMS MySQL query code and the QtRoot is innocent.[/quote]

I’ll have to look into those two libraries more carefully (I’ve not delved into them so far)…

Thank you, I need some time to dig the source code.
I’ll be back soon.

May I ask you to do two things:

  1. re-run your application against of ROOT with the debug information “in” to see where is the problem located inside of the Gl_histinit () ( This C subroutine is located within “root/clib/src/Getline.c” )

#1 0xb5ae5132 in Gl_histinit () from /usr/lib/root/libCore.so.5.13 #2 0xb5ae534d in Getlinem () from /usr/lib/root/libCore.so.5.13
What I am confused with is that there is no call from Getlinem to Gl_histinit at all. The kind of thing indicated by your call stack. Are you sure you are using the ROOT shared libraries from one and the same ROOT version?
Where is your ROOT comes from. Did you compile it yourself ? Did you re-compile everything?
With the grep shell command I found the Gl_histinit is called by ROOT from one single place:TRint.cxx:210: Gl_histinit((char *)logon);

  1. Can you re-run the code with no Gui.Prompt In this case the Getlinem () should not be called at all.

May be you should communicate this information via ROOT Bug report savannah.cern.ch/bugs/?func=add … up=savroot rather via RootForum. We will be able to publish the final solution for the Forum too.

Thank you.

[quote=“fine”]Where is your ROOT comes from. Did you compile it yourself ? Did you re-compile everything?
With the grep shell command I found the Gl_histinit is called by ROOT from one single place:TRint.cxx:210: Gl_histinit((char *)logon);[/quote]

I am currently using the Debian “unstable” packages (5.13.05 of 11-Oct-2006, compiled 2-Nov-2006) for ROOT which Chris Holm has made available in his Debian repository, mirror.phy.bnl.gov/debian-root/ .
They are working very well.

I’m quite embarassed that I didn’t think of trying this before. #-o
I did remove the line, namely

gEnv->SetValue("Gui.Prompt","false");

or more exactly

gEnv->SetValue("myprogram.Gui.Prompt","false");

and it worked, the application no longer hangs. :blush:
But I’m still confused as to why that apparently innocuous line has caused that small problem… anyway it’s removed :slight_smile:

I would consider this issue solved; however, if you’re interested I may conduct more tests and post them either here or elsewhere.

Thank you once again! :mrgreen:

[quote=“jbatista”]I would consider this issue solved; however, if you’re interested I may conduct more tests and post them either here or elsewhere.[/quote] I have introduced an extra protection. You should not see that problem anymore with the coming ROOT 5.14 release.
Thank you