2010-05-26 22 views
0

En essayant d'exécuter a C++ program, je reçois des erreurs de segmentation qui semblent être spécifiques à NetBSD. Bert Hubert a écrit le programme de test simple (à la fin de ce message) et, en effet, il se bloque uniquement sur NetBSD.Segfaults de stockage local par thread sur NetBSD uniquement?

% 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) 

Sur d'autres Unix, cela fonctionne très bien. Y at-il un problème connu dans NetBSD avec C++ thread-local de stockage?

#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); 
} 

Répondre

1

NetBSD ne prend pas en charge le stockage local sur le thread. La plupart des autres BSD font cependant.

+0

Existe-t-il un moyen propre de détecter cela au moment de la compilation ou de l'exécution, pour produire un meilleur message d'erreur? Une règle autoconf existante, par exemple? – bortzmeyer

+0

Un pointeur vers la documentation NetBSD à ce propos? Je n'ai pas réussi à le trouver avec les moteurs de recherche. – bortzmeyer

+1

http://www.mail-archive.com/[email protected]/msg04644.html est le meilleur que j'ai pu trouver. – Joe