[Bug 1876958] Re: Ubuntu-specific pthread issue

Matthias Klose 1876958 at bugs.launchpad.net
Tue Mar 9 14:32:16 UTC 2021


The Ubuntu GCC turns on -fstack-protector by default. You get the same
results when turning this off.

However building and running your program with -fsanitize=address
suggests that your program is wrong.


** Changed in: gcc-defaults (Ubuntu)
       Status: New => Invalid

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-defaults in Ubuntu.
https://bugs.launchpad.net/bugs/1876958

Title:
  Ubuntu-specific pthread issue

Status in gcc-defaults package in Ubuntu:
  Invalid

Bug description:
  The following c++11 program works properly (prints fn1 and fn2) on
  every system and compiler I have checked except for Ubuntu - where it
  prints (fn2 and fn2).  This happens on both laptop and server installs
  of Ubuntu 18.04.

  All system gcc packages on my Ubuntu 18.04 system show the same (incorrect) output:
  g++-5 (Ubuntu 5.5.0-12ubuntu1) 5.5.0 20171010
  g++-6 (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026
  g++-7 (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
  g++-8 (Ubuntu 8.3.0-26ubuntu1~18.04) 8.3.0

  Notes:
   - Re-compiling gcc from source eliminates the problem.
   - I have not checked any Ubuntu versions other than 18.04.

  Off-topic note:
   - this may be a [libpthread bug](https://bugs.launchpad.net/ubuntu/+source/libpthread-stubs/)?

  /* Minimal bug-reproducer for gcc on ubuntu */
  #include <functional>
  #include <thread>
  #include <stdio.h>

  struct run {
      const std::function<void()> &fn;
      run(const std::function<void()> &fn_) : fn(fn_) {}

      void operator()() {
          fn();
      }
  };

  int main() {
      auto fn1 = [](){ printf("fn1\n"); };
      auto r1 = run(fn1);
      auto fn2 = [](){ printf("fn2\n"); };
      auto r2 = run(fn2);
      std::thread t1( r1 );
      std::thread t2( r2 );
      t1.join();
      t2.join();
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1876958/+subscriptions



More information about the foundations-bugs mailing list