C++ Exception Crash Analysis on Sparc SIS.

Thomas Kim thomas73.kim at gmail.com
Mon Mar 31 15:34:06 UTC 2014


I am testing cxx_throw example on Sparc SIS using rtems 4.10.99 and rtems
toolchain(gcc 4.8.2).
Because cxx_throw example is not working, I am analyzing this problem.

I post backtrace information regarding this.
------------------------------------------------------------------------------------------------------------------------------------
Breakpoint 1, classify_object_over_fdes (ob=ob at entry=0x2067de8
<object.2802>,
    this_fde=0x2060703 <__EH_FRAME_BEGIN__+3>) at
../../../gcc-4.8.2/libgcc/unwind-dw2-fde.c:613
613  for (; ! last_fde (ob, this_fde); this_fde = next_fde (this_fde))
(gdb) bt
#0  classify_object_over_fdes (ob=ob at entry=0x2067de8 <object.2802>,
this_fde=0x2060703 <__EH_FRAME_BEGIN__+3>)
    at ../../../gcc-4.8.2/libgcc/unwind-dw2-fde.c:613
#1  0x0203503c in init_object (ob=0x2067de8 <object.2802>) at
../../../gcc-4.8.2/libgcc/unwind-dw2-fde.c:750
#2  search_object (ob=ob at entry=0x2067de8 <object.2802>, pc=pc at entry=0x2033e1b
<_Unwind_RaiseException+23>)
    at ../../../gcc-4.8.2/libgcc/unwind-dw2-fde.c:962
#3  0x02035760 in _Unwind_Find_FDE (pc=0x2033e1b
<_Unwind_RaiseException+23>, bases=bases at entry=0x2072944)
    at ../../../gcc-4.8.2/libgcc/unwind-dw2-fde.c:1026
#4  0x0203212c in uw_frame_state_for (context=context at entry=0x2072798,
fs=fs at entry=0x20723c8)
    at ../../../gcc-4.8.2/libgcc/unwind-dw2.c:1245
#5  0x02033564 in uw_init_context_1 (context=context at entry=0x2072798,
outer_cfa=outer_cfa at entry=0x2072f60, outer_ra=
    0x2001db0 <__cxxabiv1::__cxa_throw(void*, std::type_info*, void
(*)(void*))+80>)
    at ../../../gcc-4.8.2/libgcc/unwind-dw2.c:1566
#6  0x02033e1c in _Unwind_RaiseException (exc=0x20743c8) at
../../../gcc-4.8.2/libgcc/unwind.inc:88
#7  0x02001db8 in __cxxabiv1::__cxa_throw (obj=0x20743e0, tinfo=0x2060b48
<typeinfo for char const*>, dest=0x0)
    at ../../../../gcc-4.8.2/libstdc++-v3/libsupc++/eh_throw.cc:79
#8  0x020017d0 in cdtest () at init.cc:124
#9  0x020018c0 in Init () at init.cc:149
#10 0x02045320 in _Thread_Handler () at
../../../../../../rtems/c/src/../../cpukit/score/src/threadhandler.c:192
#11 0x02045228 in _Thread_Handler () at
../../../../../../rtems/c/src/../../cpukit/score/src/threadhandler.c:94
------------------------------------------------------------------------------------------------------------------------------------

I found the reason "memory address not aligned" error message.
http://theofilos.cs.columbia.edu/blog/2013/09/22/base_abi/
As I know in this URL, eh_frame section is needed for handling C++
exception.
But, If orignal linkcmds.base is used, eh_frame section is not generated.
In this case, _EH_FRAME_BEGIN_ is pointed to __CTORS_LIST__.

02060700 <__CTOR_LIST__>:
 2060700: ff ff ff ff 02 00 18 e8 02 00 20 b8 02 00 2f 94     ..........
.../.
 2060710: 02 01 12 f4 02 02 f2 98 02 03 00 84                 ............

Error line is 613 of unwind-dw2-fde.c as like below;

classify_object_over_fdes (struct object *ob, const fde *this_fde)
{
  const struct dwarf_cie *last_cie = 0;
  size_t count = 0;
  int encoding = DW_EH_PE_absptr;
  _Unwind_Ptr base = 0;

  for (; ! last_fde (ob, this_fde); this_fde = next_fde (this_fde)) ==>
Error Here !!!
  ...
}

static inline const fde *
next_fde (const fde *f)
{
  return (const fde *) ((const char *) f + f->length + sizeof (f->length));
}

f = 0x2060700
f->length = 0xffffffff
sizeof (f->length) = 4

fde return 0x2060703.

At this time, I am tring to modify linkcmd.base for generating eh_frame
section.

I modified linkcmd.base as like below;

 .text :
  {
    CREATE_OBJECT_SYMBOLS
    text_start = .;
    _text_start = .;
    *(.text*)
    . = ALIGN (16);

    *(.eh_frame_hdr) ==> Added!!!
    *(.eh_frame)
    *(.gcc_except_table .gcc_except_table.*)  ==> Added!!!
   ...
}

After I changed this, cxx_throw executable is changed. that is,
__EH_FRAME_BEGIN of eh_frame is generated.

020603f0 <__EH_FRAME_BEGIN__>:
 20603f0: ff ff 01 0e 24 18 84 01 00 60 10 00 00 8c 01 08
....$....`......
 2060400: 00 00 ff ff 01 0e 24 18 84 01 00 60 10 00 00 8c
......$....`....
 2060410: 01 08 00 00 ff ff 01 0e 2c 10 00 00 74 10 98 01
........,...t...
 2060420: 00 a0 01 08 00 00 00 00 ff 00 65 01 5b 2c 10 00
..........e.[,..
 ....
02061610 <__CTOR_LIST__>:
 2061610: ff ff ff ff 02 00 18 e8 02 00 20 b8 02 00 2f 94     ..........
.../.
 2061620: 02 01 12 f4 02 02 f2 98 02 03 00 84                 ............

0206162c <__CTOR_END__>:
 206162c: 00 00 00 00                                         ....

But, even though __EH_FRAME_BEGIN__ is generated, unwind exception
processing is not working.
current error log is below;

*** CONSTRUCTOR/DESTRUCTOR TEST ***
Hey I'm in base class constructor number 4 for 0x2072d00.
Hey I'm in base class constructor number 5 for 0x2072d08.
Hey I'm in base class constructor number 6 for 0x2072d10.
Hey I'm in base class constructor number 7 for 0x2072d18.
Hey I'm in derived class constructor number 8 for 0x2072d18.
Testing a C++ I/O stream
before try block
Memory exception at dded7ffc (illegal address)
Unexpected trap ( 9) at address 0x02049980
data access exception at 0xDDED7FFC
IU in error mode (257)
   367917  020363cc  91d02000  Address 0x020363cc is out of bounds.


Do you have any idea for resolving this ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20140401/add1de5e/attachment.html>


More information about the users mailing list