Trolltech Home | Qt-embedded-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-embedded-interest Archive, April 2007
QT Multi Thread segmentation fault


Message 1 in thread

Hi all,

I'm writing to you in the hope you help me to solve a problem. I'm
developing a qt-embedded application which should get Image from MJPEG
stream and paint them at run time.

Application is made up essentially by 2 components:

1) producer (parses MJPEG stream from tcp socket, gets image and puts it
into shared buffer);
2) consumer/lettore (paints image while it is available from shared buffer)

I need to show 4 MJPEG sources I have to run 4 procuders and 4 consumers
in the same application


Using mutex and waitconditions threads seems to work fine and MJPEG
stream is available on frame buffer screen

The application seems to work fine, except for some random crashes;
example of crashes are shown below:

//TEST1
(gdb) run -qws
Starting program: /var/www/video2/spool/.QT_TEMP/PROJECT/Monitor/Monitor
-qws
[Thread debugging using libthread_db enabled]
[New Thread 47473253063840 (LWP 2390)]
ting mouse: Auto
Stato: 2
[New Thread 1082128752 (LWP 2393)]
[New Thread 1090517360 (LWP 2394)]
[New Thread 1098905968 (LWP 2395)]
[New Thread 1107294576 (LWP 2396)]
[New Thread 1115683184 (LWP 2397)]
[New Thread 1124071792 (LWP 2398)]
[New Thread 1132460400 (LWP 2399)]
[New Thread 1140849008 (LWP 2400)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1115683184 (LWP 2397)]
0x00002b2d3a24b4e3 in mallopt () from /lib/libc.so.6
(gdb) where
#0  0x00002b2d3a24b4e3 in mallopt () from /lib/libc.so.6
#1  0x00002b2d3a24ad80 in mallopt () from /lib/libc.so.6
#2  0x00002b2d3a249ff7 in malloc () from /lib/libc.so.6
#3  0x00002b2d39dff8a5 in operator new () from /usr/lib/libstdc++.so.5
#4  0x00002aaaaaab1cb4 in ?? () from /usr/plugins/imageformats/libqjpeg.so
#5  0x00002b2d39764cf4 in QImageIO::read () from /usr/lib/libqte-mt.so.3
#6  0x00002b2d39763522 in QImage::loadFromData () from
/usr/lib/libqte-mt.so.3
#7  0x0000000000409ed2 in ScrittoreSocket::run ()
#8  0x00002b2d39735c47 in QThreadInstance::start () from
/usr/lib/libqte-mt.so.3
#9  0x00002b2d3a51ab55 in start_thread () from /lib/libpthread.so.0
#10 0x00002b2d3a2a57f0 in clone () from /lib/libc.so.6

//Test2
(gdb) run -qws
Starting program: /var/www/video2/spool/.QT_TEMP/PROJECT/Monitor/Monitor
-qws
[Thread debugging using libthread_db enabled]
[New Thread 47147663482016 (LWP 2547)]
ting mouse: Auto
Stato: 2
[New Thread 1082128752 (LWP 2550)]
[New Thread 1090517360 (LWP 2551)]
[New Thread 1098905968 (LWP 2552)]
[New Thread 1107294576 (LWP 2553)]
[New Thread 1115683184 (LWP 2554)]
[New Thread 1124071792 (LWP 2555)]
[New Thread 1132460400 (LWP 2556)]
[New Thread 1140849008 (LWP 2557)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1107294576 (LWP 2553)]
0x00002ae16b7df2cd in mallopt () from /lib/libc.so.6
(gdb) bt
#0  0x00002ae16b7df2cd in mallopt () from /lib/libc.so.6
#1  0x00002ae16b7de1a2 in free () from /lib/libc.so.6
#2  0x00002ae16b3924fe in operator delete () from /usr/lib/libstdc++.so.5
#3  0x00002ae16ac5c7fc in QRegion::operator= () from /usr/lib/libqte-mt.so.3
#4  0x00002ae16ac520a2 in qt_set_paintevent_clipping () from
/usr/lib/libqte-mt.so.3
#5  0x00002ae16ac5e70f in QWidget::repaint () from /usr/lib/libqte-mt.so.3
#6  0x0000000000409ad1 in Lettore::run ()
#7  0x00002ae16acc9c47 in QThreadInstance::start () from
/usr/lib/libqte-mt.so.3
#8  0x00002ae16baaeb55 in start_thread () from /lib/libpthread.so.0
#9  0x00002ae16b8397f0 in clone () from /lib/libc.so.6

PS: Buffer which contains JPEG image has not corrupted format

---------------------
demosurveillance:~# gcc -v
Reading specs from /usr/lib/gcc-lib/x86_64-linux/3.3.5/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared
--enable-__cxa_atexit --with-system-zlib --enable-nls
--without-included-gettext --enable-clocale=gnu --enable-debug
--enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc
--disable-multilib x86_64-linux
Thread model: posix
gcc version 3.3.5 (Debian 1:3.3.5-13)

----------------------
qt-embedded-free-3.3.8

./configure -thread -freetype -prefix /usr

Thanks in advance

BR

To unsubscribe - send "unsubscribe" in the subject to qt-embedded-interest-request@xxxxxxxxxxxxx


Message 2 in thread

Hi,

> [...]
> #0  0x00002b2d3a24b4e3 in mallopt () from /lib/libc.so.6
> #1  0x00002b2d3a24ad80 in mallopt () from /lib/libc.so.6
> #2  0x00002b2d3a249ff7 in malloc () from /lib/libc.so.6
> #3  0x00002b2d39dff8a5 in operator new () from /usr/lib/libstdc++.so.5
> #4  0x00002aaaaaab1cb4 in ?? () from /usr/plugins/imageformats/libqjpeg.so
> [...]
> #0  0x00002ae16b7df2cd in mallopt () from /lib/libc.so.6
> #1  0x00002ae16b7de1a2 in free () from /lib/libc.so.6
> #2  0x00002ae16b3924fe in operator delete () from /usr/lib/libstdc++.so.5
> #3  0x00002ae16ac5c7fc in QRegion::operator= () from /usr/lib/libqte-mt.so.3

Since these errors happen in malloc()/free(), chances are this is a memory 
corruption issues.

Have you tried running your application in Valgrind?

--
 [ signature omitted ] 

Message 3 in thread

Dimitri ha scritto:
> Hi,
>
>> [...]
>> #0  0x00002b2d3a24b4e3 in mallopt () from /lib/libc.so.6
>> #1  0x00002b2d3a24ad80 in mallopt () from /lib/libc.so.6
>> #2  0x00002b2d3a249ff7 in malloc () from /lib/libc.so.6
>> #3  0x00002b2d39dff8a5 in operator new () from /usr/lib/libstdc++.so.5
>> #4  0x00002aaaaaab1cb4 in ?? () from
>> /usr/plugins/imageformats/libqjpeg.so
>> [...]
>> #0  0x00002ae16b7df2cd in mallopt () from /lib/libc.so.6
>> #1  0x00002ae16b7de1a2 in free () from /lib/libc.so.6
>> #2  0x00002ae16b3924fe in operator delete () from
>> /usr/lib/libstdc++.so.5
>> #3  0x00002ae16ac5c7fc in QRegion::operator= () from
>> /usr/lib/libqte-mt.so.3
>
> Since these errors happen in malloc()/free(), chances are this is a
> memory corruption issues.
>
> Have you tried running your application in Valgrind?
>
> -- 
> Dimitri
>
> To unsubscribe - send "unsubscribe" in the subject to
> qt-embedded-interest-request@xxxxxxxxxxxxx
>

Hi Dimitri,

Thanks for your reply its much appreciated.

I ran application with Valgrind few days ago and I was not able to get
some useful information.

Now I'm going to use Valgrind and hope this helps



BR




To unsubscribe - send "unsubscribe" in the subject to qt-embedded-interest-request@xxxxxxxxxxxxx


Message 4 in thread

Giovanni Licata ha scritto:
> Dimitri ha scritto:
>   
>> Hi,
>>
>>     
>>> [...]
>>> #0  0x00002b2d3a24b4e3 in mallopt () from /lib/libc.so.6
>>> #1  0x00002b2d3a24ad80 in mallopt () from /lib/libc.so.6
>>> #2  0x00002b2d3a249ff7 in malloc () from /lib/libc.so.6
>>> #3  0x00002b2d39dff8a5 in operator new () from /usr/lib/libstdc++.so.5
>>> #4  0x00002aaaaaab1cb4 in ?? () from
>>> /usr/plugins/imageformats/libqjpeg.so
>>> [...]
>>> #0  0x00002ae16b7df2cd in mallopt () from /lib/libc.so.6
>>> #1  0x00002ae16b7de1a2 in free () from /lib/libc.so.6
>>> #2  0x00002ae16b3924fe in operator delete () from
>>> /usr/lib/libstdc++.so.5
>>> #3  0x00002ae16ac5c7fc in QRegion::operator= () from
>>> /usr/lib/libqte-mt.so.3
>>>       
>> Since these errors happen in malloc()/free(), chances are this is a
>> memory corruption issues.
>>
>> Have you tried running your application in Valgrind?
>>
>> -- 
>> Dimitri
>>
>> To unsubscribe - send "unsubscribe" in the subject to
>> qt-embedded-interest-request@xxxxxxxxxxxxx
>>
>>     
>
> Hi Dimitri,
>
> Thanks for your reply its much appreciated.
>
> I ran application with Valgrind few days ago and I was not able to get
> some useful information.
>
> Now I'm going to use Valgrind and hope this helps
>
>
>
> BR
>
>
>
>   

Hi Dimitri,

Valgrind reports me the following results:

...
...
...
==1230==
==1230== Thread 1:
==1230== Invalid free() / delete / delete[]
==1230==    at 0x4A19C3D: free (vg_replace_malloc.c:233)
==1230==    by 0x5A33D6A: (within /lib/libc-2.3.2.so)
==1230==    by 0x5A33A34: __libc_freeres (in /lib/libc-2.3.2.so)
==1230==    by 0x49168AB: _vgnU_freeres (vg_preloaded.c:60)
==1230==    by 0x4E1F675: QLock::lock(QLock::Type) (in
/usr/lib/libqte-mt.so.3.3.8)
==1230==    by 0x4E454FE: QWSRegionManager::commit() (in
/usr/lib/libqte-mt.so.3.3.8)
==1230==    by 0x4E39AB4: QWSServer::raiseWindow(QWSWindow*, int) (in
/usr/lib/libqte-mt.so.3.3.8)
==1230==    by 0x4E39120:
QWSServer::invokeSetAltitude(QWSChangeAltitudeCommand const*,
QWSClient*) (in /usr/lib/libqte-mt.so.3.3.8)
==1230==    by 0x4E3ABA7:
QWSServer::set_altitude(QWSChangeAltitudeCommand const*) (in
/usr/lib/libqte-mt.so.3.3.8)
==1230==    by 0x4DF7CAA: QWSDisplay::setAltitude(int, int, bool) (in
/usr/lib/libqte-mt.so.3.3.8)
==1230==    by 0x4E30985: QWidget::showWindow() (in
/usr/lib/libqte-mt.so.3.3.8)
==1230==    by 0x4F1E38B: QWidget::show() (in /usr/lib/libqte-mt.so.3.3.8)
==1230==  Address 0x401ADB8 is not stack'd, malloc'd or (recently) free'd

Thanks in advance

BR




To unsubscribe - send "unsubscribe" in the subject to qt-embedded-interest-request@xxxxxxxxxxxxx


Message 5 in thread

Hi,

> Valgrind reports me the following results:
> [...]
> ==1230== Invalid free() / delete / delete[]
> ==1230==    at 0x4A19C3D: free (vg_replace_malloc.c:233)
> ==1230==    by 0x5A33D6A: (within /lib/libc-2.3.2.so)
> ==1230==    by 0x5A33A34: __libc_freeres (in /lib/libc-2.3.2.so)
> ==1230==    by 0x49168AB: _vgnU_freeres (vg_preloaded.c:60)
> ==1230==    by 0x4E1F675: QLock::lock(QLock::Type) (in
> /usr/lib/libqte-mt.so.3.3.8)

Strange, I don't see any call to free/delete in QLock::lock(). Are there any 
other errors (possibly in your program) before that one?

Also it would help if you could build a debug version of the Qt library and of 
your program to track this down.

--
 [ signature omitted ] 

Message 6 in thread

Dimitri ha scritto:
> Hi,
>
Hi Dimitri,
>> Valgrind reports me the following results:
>> [...]
>> ==1230== Invalid free() / delete / delete[]
>> ==1230==    at 0x4A19C3D: free (vg_replace_malloc.c:233)
>> ==1230==    by 0x5A33D6A: (within /lib/libc-2.3.2.so)
>> ==1230==    by 0x5A33A34: __libc_freeres (in /lib/libc-2.3.2.so)
>> ==1230==    by 0x49168AB: _vgnU_freeres (vg_preloaded.c:60)
>> ==1230==    by 0x4E1F675: QLock::lock(QLock::Type) (in
>> /usr/lib/libqte-mt.so.3.3.8)
>
> Strange, I don't see any call to free/delete in QLock::lock(). Are
> there any other errors (possibly in your program) before that one?
>
> Also it would help if you could build a debug version of the Qt
> library and of your program to track this down.
>

I have already tried to use debug version of the Qt library but I never 
got errors inside my  program.

Program should display incoming images from 4 different sources inside
the same application (4 Producer and Consumer pairs).

I have checked that running only Producer and Consumer as single QT
Application does not produce any memory corruption.

Thanks for your kind attention

BR


> -- 
> Dimitri
>
> To unsubscribe - send "unsubscribe" in the subject to
> qt-embedded-interest-request@xxxxxxxxxxxxx
>

To unsubscribe - send "unsubscribe" in the subject to qt-embedded-interest-request@xxxxxxxxxxxxx


Message 7 in thread

Hi,

> I have already tried to use debug version of the Qt library but I never 
> got errors inside my  program.

I thought a debug version of the Qt library and of the program might result in 
better Valgrind error messages, such as lien numbers in source files, but I 
may be wrong - I don"t really recall what the Valgrind output looks like.

--
 [ signature omitted ]