Public bug reported:

Binary package hint: gcc-4.3

$ lsb_release -rd
Description:    Ubuntu 9.04
Release:        9.04

$ apt-cache policy libstdc++6
libstdc++6:
  Installed: 4.3.3-5ubuntu4
  Candidate: 4.3.3-5ubuntu4
  Version table:
 *** 4.3.3-5ubuntu4 0
        500 http://us.archive.ubuntu.com jaunty/main Packages
        100 /var/lib/dpkg/status

$ apt-cache policy gcc
gcc:
  Installed: 4:4.3.3-1ubuntu1
  Candidate: 4:4.3.3-1ubuntu1
  Version table:
 *** 4:4.3.3-1ubuntu1 0
        500 http://us.archive.ubuntu.com jaunty/main Packages
        100 /var/lib/dpkg/status

This is a bit tricky to provide details for but I'll do my best.

I develop a custom multi-threaded c++ trading application that I run on
a Juanty server.  My application seems to be deadlocking on a line where
I create an ostringstream.  This seems to be releated to
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40088 and the underling lock
is in std::locale::locale().

gdb reports the following when I attach to the deadlocked program:
$ gdb tradesys
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...

(gdb) attach 30145
Attaching to program: /usr/local/opt_to_link/ram1/tradesys, process 30145
Reading symbols from /lib/libpthread.so.0...done.
[Thread debugging using libthread_db enabled]
[New Thread 0x7ff747475700 (LWP 30145)]
[New Thread 0x7ff744535950 (LWP 30150)]
[New Thread 0x7ff744d36950 (LWP 30149)]
[New Thread 0x7ff745537950 (LWP 30148)]
[New Thread 0x7ff745d38950 (LWP 30147)]
[New Thread 0x7ff746539950 (LWP 30146)]
Loaded symbols for /lib/libpthread.so.0
Reading symbols from /usr/lib/libstdc++.so.6...done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux-x86-64.so.2...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
0x00007ff747063a94 in __lll_lock_wait () from /lib/libpthread.so.0

(gdb) bt
#0  0x00007ff747063a94 in __lll_lock_wait () from /lib/libpthread.so.0
#1  0x00007ff74705f190 in _L_lock_102 () from /lib/libpthread.so.0
#2  0x00007ff74705ea7e in pthread_mutex_lock () from /lib/libpthread.so.0
#3  0x00007ff746db28ef in std::locale::locale () from /usr/lib/libstdc++.so.6
#4  0x00007ff746de83ce in std::basic_ostringstream<char, 
std::char_traits<char>, std::allocator<char> >::basic_ostringstream () from 
/usr/lib/libstdc++.so.6
#5  0x00000000004680c2 in mainLoop (logi...@0x7fff4f491aa0, status_log=0xf52380,
    broker=0xf54a60, portfolio=0xf540c0, cme=0xf81690, trade...@0x7fff4f491a70,
    stop_trading_server=0x1061e20) at tradsys.cpp:363
#6  0x000000000046ac95 in main (argc=2, argv=0x7fff4f491be8) at tradesys.cpp:212

(gdb) info threads
  6 Thread 0x7ff746539950 (LWP 30146)  0x00007ff747063a94 in __lll_lock_wait ()
   from /lib/libpthread.so.0
  5 Thread 0x7ff745d38950 (LWP 30147)  0x00007ff747063a94 in __lll_lock_wait ()
   from /lib/libpthread.so.0
  4 Thread 0x7ff745537950 (LWP 30148)  0x00007ff74706415b in accept ()
   from /lib/libpthread.so.0
  3 Thread 0x7ff744d36950 (LWP 30149)  0x00007ff7470647e1 in nanosleep ()
   from /lib/libpthread.so.0
  2 Thread 0x7ff744535950 (LWP 30150)  0x00007ff7470647e1 in nanosleep ()
   from /lib/libpthread.so.0
  1 Thread 0x7ff747475700 (LWP 30145)  0x00007ff747063a94 in __lll_lock_wait ()
   from /lib/libpthread.so.0

For reference lines 362-364 in tradesys.cpp are:
  cout << "Main thread woke up." << endl;
  ostringstream msg;
  cout << endl << "******* SYSTEM STATUS **********" << endl;
The first cout did output but the second did not.

Please let me know if I can be of more assistance in diagnosing or
fixing this problem.

** Affects: gcc-4.3 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
Creating ostringstream causes deadlock
https://bugs.launchpad.net/bugs/453518
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to