X32 and __gnu_cxx::__exchange_and_add_single?

383 views Asked by At

I'm trying to understand a crash in a library that's undergoing testing on X32 platform (x86_64 with ILP32). When I backtrace it, I see:

(gdb) bt full
#0  0xf6e02e1b in _Unwind_Resume ()
   from /lib/x86_64-linux-gnux32/libgcc_s.so.1
No symbol table info available.
#1  0x00454b12 in __gnu_cxx::__exchange_and_add_single (
    __val=<optimized out>, __mem=<optimized out>)
    at /usr/include/c++/6/ext/atomicity.h:68
        __result = <optimized out>
#2  __gnu_cxx::__exchange_and_add_dispatch (__val=0xffffffff, __mem=0x8)
    at /usr/include/c++/6/ext/atomicity.h:84
No locals.
#3  std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x0)
    at /usr/include/c++/6/bits/shared_ptr_base.h:162
No locals.
#4  std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (
    this=0xffffaa78, __in_chrg=<optimized out>)
    at /usr/include/c++/6/bits/shared_ptr_base.h:662
No locals.
...

And:

(gdb) f 1
#1  0x00454b12 in __gnu_cxx::__exchange_and_add_single (
    __val=<optimized out>, __mem=<optimized out>)
    at /usr/include/c++/6/ext/atomicity.h:68
68      *__mem += __val;
(gdb) p __mem
$1 = <optimized out>
(gdb) p __val
$2 = <optimized out>

When I looked at the disassembly I see the following. $pc is 0x454b12: mov %eax,%ebx.

(gdb) x/6i $pc-4
   0x454b0e:    push   %rbx
   0x454b0f:    or     %ch,%bl
   0x454b11:    outsl  %ds:(%rsi),(%dx)
   0x454b12:    mov    %eax,%ebx
   0x454b14:    mov    -0x170(%ebp),%eax
   0x454b1b:    lea    -0x168(%rbp),%edx

The outsl looks unusual to me for the __gnu_cxx::__exchange_and_add_single.

Can anyone explain what's going on with the __gnu_cxx::__exchange_and_add_single code that's being generated?


$ gcc -dumpmachine
x86_64-linux-gnux32

$ gcc --version   
gcc (Debian 6.3.0-2) 6.3.0 20161229
Copyright (C) 2016 Free Software Foundation, Inc.
...
0

There are 0 answers