Hello,
I am working on a cross plateform DICOM lib which seems to be working
fairly well on a variety of plateforms except on MacOSX with gcc.
If I try to run any example it gets stuck on a string construction. I
believe this has to do with multi thread and c++ object initialization
on the Mac. Could someone comment on the usage in a header file of:
static const std::string foo = "bar";
Is this a bad practice ? Can it be safely replace by something else
that would be more 'conventional/robust' ? BTW I cannot change this to a
regular 'const char foo[]' since I am returning direct const reference
to this object.
I include the gdb backtrace, hopefully this should mean something for
someone :)
Thanks
Mathieu
$ gcc --version
gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1671)
$ gdbrun ./bin/gdcmTests TestUtil GNU gdb 5.3-20030128 (Apple version
gdb-330.1) (Fri Jul 16 21:42:28 GMT 2004)
Copyright 2003 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 "powerpc-apple-darwin".
Reading symbols for shared libraries ........ done
Reading symbols for shared libraries ++++..... done
^C
Program received signal SIGINT, Interrupt.
0x90016f48 in semaphore_wait_signal_trap ()
(gdb) bt
#0 0x90016f48 in semaphore_wait_signal_trap ()
#1 0x900021e0 in pthread_mutex_lock ()
#2 0x00c17b6c in std::string::_Rep::_S_create(unsigned long,
std::allocator<char> const&) () at
/usr/include/gcc/darwin/3.3/c++/iostream:76
#3 0x00c18808 in char* std::string::_S_construct<char const*>(char
const*, char const*, std::allocator<char> const&,
std::forward_iterator_tag) () at
/usr/include/gcc/darwin/3.3/c++/iostream:76
#4 0x00c14fdc in std::string::string(char const*, std::allocator<char>
const&) () at /usr/include/gcc/darwin/3.3/c++/iostream:76
#5 0x00c9b6d4 in __static_initialization_and_destruction_0(int, int)
(__initialize_p=1, __priority=65535) at /Users/kitware/Dashboards/My
Tests/gdcm/src/gdcmCommon.h:81
#6 0x00c9c044 in _GLOBAL__I__ZN4gdcm8BinEntryC2EPNS_9DictEntryE () at
/Users/kitware/Dashboards/My Tests/gdcm/src/gdcmCommon.h:56
#7 0x8fe17728 in __dyld_call_module_initializers_for_library ()
#8 0x8fe174a0 in __dyld_call_module_initializers ()
#9 0x8fe11704 in __dyld_link_in_need_modules ()
#10 0x8fe110e8 in __dyld_bind_lazy_symbol_reference ()
#11 0x8fe01340 in __dyld_stub_binding_helper_interface ()
#12 0x00c14758 in std::__default_alloc_template<true,
0>::_S_chunk_alloc(unsigned long, int&) () at
/usr/include/gcc/darwin/3.3/c++/iostream:76
#13 0x00c145f8 in std::__default_alloc_template<true,
0>::_S_refill(unsigned long) () at
/usr/include/gcc/darwin/3.3/c++/iostream:76
#14 0x00c17b80 in std::string::_Rep::_S_create(unsigned long,
std::allocator<char> const&) () at
/usr/include/gcc/darwin/3.3/c++/iostream:76
#15 0x00c18808 in char* std::string::_S_construct<char const*>(char
const*, char const*, std::allocator<char> const&,
std::forward_iterator_tag) () at
/usr/include/gcc/darwin/3.3/c++/iostream:76
#16 0x00c14fdc in std::string::string(char const*, std::allocator<char>
const&) () at /usr/include/gcc/darwin/3.3/c++/iostream:76
#17 0x00c9abc8 in __static_initialization_and_destruction_0(int, int)
(__initialize_p=1, __priority=65535) at /Users/kitware/Dashboards/My
Tests/gdcm/src/gdcmCommon.h:81
#18 0x00c9b538 in _GLOBAL__I__ZN4gdcm4BaseC2Ev () at
/Users/kitware/Dashboards/My Tests/gdcm/src/gdcmCommon.h:81
#19 0x8fe17728 in __dyld_call_module_initializers_for_library ()
#20 0x8fe174a0 in __dyld_call_module_initializers ()
#21 0x8fe11704 in __dyld_link_in_need_modules ()
#22 0x8fe1124c in __dyld_bind_lazy_symbol_reference ()
#23 0x8fe01340 in __dyld_stub_binding_helper_interface ()
#24 0x00005cc0 in TestUtil(int, char**) () at
/Users/kitware/Dashboards/My Tests/gdcm/Test/TestUtil.cxx:27
#25 0x0000346c in main (ac=1, av=0xbffffc64) at
/Users/kitware/Dashboards/My Tests/gdcm-gcc/Test/gdcmTests.cxx:209
(gdb) up
#1 0x900021e0 in pthread_mutex_lock ()
(gdb)
#2 0x00c17b6c in std::string::_Rep::_S_create(unsigned long,
std::allocator<char> const&) () at
/usr/include/gcc/darwin/3.3/c++/iostream:76
76 // For construction of filebuffers for cout, cin, cerr, clog
et. al.
(gdb)
#3 0x00c18808 in char* std::string::_S_construct<char const*>(char
const*, char const*, std::allocator<char> const&,
std::forward_iterator_tag) () at
/usr/include/gcc/darwin/3.3/c++/iostream:76
76 // For construction of filebuffers for cout, cin, cerr, clog
et. al.
(gdb)
#4 0x00c14fdc in std::string::string(char const*, std::allocator<char>
const&) () at /usr/include/gcc/darwin/3.3/c++/iostream:76
76 // For construction of filebuffers for cout, cin, cerr, clog
et. al.
(gdb)
#5 0x00c9b6d4 in __static_initialization_and_destruction_0(int, int)
(__initialize_p=1, __priority=65535) at /Users/kitware/Dashboards/My
Tests/gdcm/src/gdcmCommon.h:81
81 static const std::string GDCM_UNKNOWN = "gdcm::Unknown";
(gdb)