[LLVMbugs] [Bug 19254] New: c++11 static thread_local members may cause a segfault when accessed via 'this->'

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Mar 26 09:45:20 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19254

            Bug ID: 19254
           Summary: c++11 static thread_local members may cause a segfault
                    when accessed via 'this->'
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: michael at ensslin.cc
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

In the following minimal example, f() causes a segfault in the compiled
program, while g() and h() don't.
Note that the error also occurs in g++.

mic at mic-nb $ cat test.cpp
#include <string>

struct A{
    static thread_local std::string s;

    void f() {
        this->s = "segv";
    }

    void g() {
        A::s =    "no segv";
    }

    void h() {
        s =       "no segv";
    }
};

thread_local std::string A::s;

int main() {
    A{}.f();
    return 0;
}

mic at mic-nb $ g++ -std=c++11 -lpthread test.cpp         
mic at mic-nb $ ./a.out 
[1]    11729 segmentation fault (core dumped)  ./a.out
mic at mic-nb $ clang++ -std=c++11 -lpthread test.cpp
mic at mic-nb $ ./a.out 
[1]    11764 segmentation fault (core dumped)  ./a.out

Precise versions of installed software:

mic at mic-nb $ g++ --version    
g++ (GCC) 4.8.2 20140206 (prerelease)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
mic at mic-nb $ clang++ --version
clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
mic at mic-nb $ uname -a
Linux mic-nb 3.13.6-1-ARCH #1 SMP PREEMPT Fri Mar 7 22:47:48 CET 2014 x86_64
GNU/Linux

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140326/c97cb584/attachment.html>


More information about the llvm-bugs mailing list