2010-05-26 55 views
0

試圖運行a C++ program,我得到的分段 似乎是特定於NetBSD的故障。伯特休伯特寫了 簡單的測試程序(在這封郵件的末尾),事實上,它只在NetBSD上崩潰。僅限NetBSD的線程本地存儲段錯誤?

% uname -a 
NetBSD golgoth 5.0.1 NetBSD 5.0.1 (GENERIC) #0: Thu Oct 1 15:46:16 CEST 2009 
[email protected]:/usr/obj/sys/arch/i386/compile/GENERIC i386 

% g++ --version 
g++ (GCC) 4.1.3 20080704 prerelease (NetBSD nb2 20081120) 
Copyright (C) 2006 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. 

% gdb thread-local-storage-powerdns 
GNU gdb 6.5 
Copyright (C) 2006 Free Software Foundation, Inc. 
GDB is free software, covered by the GNU General Public License, and you are 
welcome to change it and/or distribute copies of it under certain conditions. 
Type "show copying" to see the conditions. 
There is absolutely no warranty for GDB. Type "show warranty" for details. 
This GDB was configured as "i386--netbsdelf"... 
(gdb) run 
Starting program: /home/stephane/Programmation/C++/essais/thread-local-storage-powerdns 

Program received signal SIGSEGV, Segmentation fault. 
0x0804881b in main() at thread-local-storage-powerdns.cc:20 
20  t_a = new Bogo('a'); 
(gdb) 

在其他的Unix上,它工作正常。在NetBSD中是否有一個已知問題, C++線程本地存儲?

#include <stdio.h> 


class Bogo 
{ 
public: 

    explicit Bogo(char a) 
    { 
d_a = a; 
    } 

    char d_a; 
}; 

__thread Bogo* t_a; 

int main() 
{ 
    t_a = new Bogo('a'); 

    Bogo* b = t_a; 

    printf("%c\n", b->d_a); 
} 

回答

1

NetBSD不支持線程本地存儲。然而,其他大多數BSD都會這樣做。

+0

有沒有一種乾淨的方式來檢測,在編譯時或運行時,產生更好的錯誤信息?現有的autoconf規則,例如? – bortzmeyer 2010-05-26 16:30:54

+0

任何指向NetBSD文檔的指針?我無法通過搜索引擎找到它。 – bortzmeyer 2010-05-26 16:32:06

+1

http://www.mail-archive.com/[email protected]/msg04644.html是我能找到的最好的。 – Joe 2010-05-26 16:42:46