← Back to team overview

touch-packages team mailing list archive

[Bug 1418642] Re: GDB hangs at thread join function on Ubuntu 14.10 LE Power

 

** Changed in: gdb (Ubuntu)
       Status: New => Incomplete

** Changed in: gdb (Ubuntu)
       Status: Incomplete => Confirmed

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to gdb in Ubuntu.
https://bugs.launchpad.net/bugs/1418642

Title:
  GDB hangs at thread join function on Ubuntu 14.10 LE Power

Status in gdb package in Ubuntu:
  Confirmed

Bug description:
  ---Problem Description---
  GDB hangs at thread join function while trying to debug STM (software transacational memory) code.
    
  ---uname output---
  Linux lep8aVM1 3.16.0-7-generic #12-Ubuntu SMP Sat Aug 9 05:05:32 UTC 2014 ppc64le ppc64le ppc64le GNU/Linux
   
  Machine Type = Power 8 
    
  ---Steps to Reproduce---

  Compile:
  -----------------
  g++ s1.cpp -g -std=c++11 -fgnu-tm -lpthread -D D_STM

  sample source: s1.cpp
  -------------------
  root@lep8aVM1:~/p# cat s1.cpp
  #include <iostream>
  #include <thread>

  static const auto THR_NUM = 4;
  static const auto ITER_NUM = 1000 * 1000;

  static auto a = 0, b = 0, c = 0;

  static void thr_func()
  {
          for (auto i = 0; i < ITER_NUM; ++i)
  #ifdef D_STM
                   __transaction_atomic {
                          ++a;
                          b += 2;
                          c = a + b;
                  }
  #else
                          ++a;
                          b += 2;
                          c = a + b;
  #endif
  }

  
  int main(int argc, char *argv[])
  {
  	std::thread thr[THR_NUM];

  	for (auto &t : thr)
  		t = std::thread(thr_func);

  	for (auto &t : thr)
  		t.join();

          std::cout << "a=" << a << " b=" << b << " c=" << c <<
  std::endl;

  	return 0;
  }

  Debug a.out using gdb:
  ------------------------
  root@lep8aVM1:~/p# gdb ./a.out 
  GNU gdb (Ubuntu 7.8-0ubuntu1) 7.8
  Copyright (C) 2014 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 "powerpc64le-linux-gnu".
  Type "show configuration" for configuration details.
  For bug reporting instructions, please see:
  <http://www.gnu.org/software/gdb/bugs/>.
  Find the GDB manual and other documentation resources online at:
  <http://www.gnu.org/software/gdb/documentation/>.
  For help, type "help".
  Type "apropos word" to search for commands related to "word"...
  Reading symbols from ./a.out...done.
  (gdb) run
  Starting program: /root/p/a.out 
  Can't read symbols from system-supplied DSO at 0x3fffb7fa0000: File truncated
  [Thread debugging using libthread_db enabled]
  Using host libthread_db library "/lib/powerpc64le-linux-gnu/libthread_db.so.1".

  Breakpoint 1, main (argc=1, argv=0x3ffffffff6b8) at s1.cpp:27
  27	{
  (gdb) list
  22	#endif
  23	}
  24	
  25	
  26	int main(int argc, char *argv[])
  27	{
  28		std::thread thr[THR_NUM];
  29	
  30		for (auto &t : thr)
  31			t = std::thread(thr_func);
  (gdb) n
  28		std::thread thr[THR_NUM];
  (gdb) n
  30		for (auto &t : thr)
  (gdb) n
  31			t = std::thread(thr_func);
  (gdb) n
  [New Thread 0x3fffb72cf170 (LWP 1278)]
  30		for (auto &t : thr)
  (gdb) n
  31			t = std::thread(thr_func);
  (gdb) n
  [New Thread 0x3fffb6acf170 (LWP 1279)]
  30		for (auto &t : thr)
  (gdb) n
  31			t = std::thread(thr_func);
  (gdb) n
  [New Thread 0x3fffb62cf170 (LWP 1280)]
  30		for (auto &t : thr)
  (gdb) n
  31			t = std::thread(thr_func);
  (gdb) n
  [New Thread 0x3fffb5acf170 (LWP 1281)]
  30		for (auto &t : thr)
  (gdb) n
  33		for (auto &t : thr)
  (gdb) n
  34			t.join();
  (gdb) n
  n
  n
  n
  Here the gdb seems hangs and does not come out...

  
   The same program been tried on Ubuntu 14.10 x86 VM; gdb could able to come out and program ends normally.

  I've found that this issue happens also on upstream gdb and not only
  on ppc64 LE, but also on BE. It is also reproducible without STM.

  This is a regression added recently upstream by commit
  2adfaa28b5ba2fb78ba5113977082c4d04752bd6. I'll continue investigating.

  Found this reduced testcase that reproduces the problem without -fgnu-
  tm flag:

  $ cat test.c
  #include <stdlib.h>
  #include <stdio.h>
  #include <unistd.h>
  #include <pthread.h>

  void *func(void *arg)
  {
          int i,a;
          for (i = 0; i < 1000000; ++i)
                  a++;
          return NULL;
  }

  int main()
  {   
      pthread_t thread;

      pthread_create(&thread, NULL, func, NULL);
      pthread_join(thread, NULL);
      return 0;
  }

  $ gcc -g -lpthread test.c -o test

  Found that this commit c1a747c10948e2298083179f4e8aeed8b962e2af fixes
  the problem on upstream gdb. I'm backporting the patch for Ubuntu
  package in order to double check this.

  Backport of the commit c1a747c10948e2298083179f4e8aeed8b962e2af from
  upstream gdb against gdb-7.8.2-0ubuntu1 that fixes the problem.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1418642/+subscriptions