This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/19826] New: invalid pointer returned from __tls_get_addr with static linking


https://sourceware.org/bugzilla/show_bug.cgi?id=19826

            Bug ID: 19826
           Summary: invalid pointer returned from __tls_get_addr with
                    static linking
           Product: glibc
           Version: 2.23
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: cbaylis at gcc dot gnu.org
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

[ created from http://gcc.gnu.org/PR68802 ]

The following program fails on ARM when statically linked:

#include <cstdio>
#include <thread>

__thread int __attribute__ ((tls_model ("global-dynamic"))) x = 10;

class Thread {
  public:
    void operator()(){
      fprintf(stderr, "testing (%i) ...\n", x);
    }
};

int main(void){
  Thread t;
  std::thread th(std::ref(t));
  th.join();
  return 0;
}

Compiling:
$ arm-unknown-linux-gnueabihf-g++ -o test_static -Wall -Wl,--whole-archive
-lpthread -Wl,--no-whole-archive -static tsimple.c

when run on a raspberry pi:
$ ./test_static
Segmentation fault

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]