I have some code as follows:
uint64_t now;
std::stringstream timestamp;
...
now = GetElapsedTime();
timestamp << "@" << std::setfill('0') << std::setw(6) << (now / 1000u) << ".";
On a 64-bit Windows system this compiles and runs fine.
On a 32-bit Ubuntu Linux system the code compiles and runs fine, but then I get a segfault. The backtrace is as follows:
#0 0xb7fe132d in check_match (
undef_name=undef_name@entry=0xb7e53396 "__udivdi3",
ref=ref@entry=0xb7e1fc70, version=version@entry=0xb7fd2690, flags=1,
type_class=1, sym=0x401638, symidx=323, strtab=0x401678 "",
map=0xb7fff940, versioned_sym=0xbfffecc4, num_versions=0xbfffecc0)
at dl-lookup.c:120
#1 0xb7fe173d in do_lookup_x (
undef_name=undef_name@entry=0xb7e53396 "__udivdi3",
new_hash=new_hash@entry=4161312091, old_hash=old_hash@entry=0xbfffed44,
ref=0xb7e1fc70, result=0xbfffed4c, scope=0xb7fffa9c, i=<optimised out>,
version=0xb7fd2690, flags=1, skip=0x0, type_class=1, undef_map=0xb7fd1400)
at dl-lookup.c:406
#2 0xb7fe1f9b in _dl_lookup_symbol_x (undef_name=0xb7e53396 "__udivdi3",
undef_map=0xb7fd1400, ref=0xbfffedc4, symbol_scope=0xb7fd15b8,
version=0xb7fd2690, type_class=1, flags=1, skip_map=0x0) at dl-lookup.c:813
#3 0xb7fe6ff8 in _dl_fixup (l=<optimised out>, reloc_arg=<optimised out>)
at dl-runtime.c:112
#4 0xb7fece20 in _dl_runtime_resolve () at ../sysdeps/i386/dl-trampoline.S:43
#5 0xb7f0a15c in ?? () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#6 0xb7f0b2fe in std::ostreambuf_iterator<char, std::char_traits<char> >
std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >
::_M_insert_int<unsigned long long>(std::ostreambuf_iterator<char,
std::char_traits<char> >, std::ios_base&, char, unsigned long long) const ()
from /usr/lib/i386-linux-gnu/libstdc++.so.6
#7 0xb7f0b4b4 in std::num_put<char, std::ostreambuf_iterator<char,
std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char,
std::char_traits<char> >, std::ios_base&, char, unsigned long long) const ()
from /usr/lib/i386-linux-gnu/libstdc++.so.6
#8 0xb7f17403 in std::ostream& std::ostream::_M_insert<unsigned long long>(unsigned long
long) () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#9 0xb7f17590 in std::ostream::operator<<(unsigned long long) ()
from /usr/lib/i386-linux-gnu/libstdc++.so.6
As a guess, it seems that the gcc compiler thinks that there is an overload for the << operator with an unsigned long long value, but thinks it needs to dynamically load a library to execute it. However it doesn't seem to be able to locate the symbol. I am not sure if it has loaded a library at this point or not.
Can anyone please give me some pointers on how to solve this issue? I tried casting the value to a uint32_t but it didn't help.
Aucun commentaire:
Enregistrer un commentaire