libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] Unwinding on arm and division by zero


From: Berat, Frederic (ADITG/SW1)
Subject: [Libunwind-devel] Unwinding on arm and division by zero
Date: Mon, 16 Mar 2015 15:54:50 +0000

Hello All,

 

I’m currently using the library in order to trace remote applications once an exception is detected.

It works pretty well for almost all the exceptions, but I encounter some unexpected behavior on division by 0 (as an example).

 

Using a sample application I get the following backtrace using the library:

====== backtrace:

261: exchnd_test

/lib/libpthread-2.18.so(raise+0x24)[0x76eea93c]

/bin/exchnd_test(__aeabi_ldiv0+0xc)[0xb108]

 

From this point unw_step returns 0.

 

Meanwhile, if I use GDB on the same application:

(gdb) bt

#0  0x76fbe93c in raise () from /lib/libpthread.so.0

#1  0x0000b108 in __aeabi_ldiv0 () at /arm-none-linux-gnueabi/src/gcc/libgcc/config/arm/lib1funcs.S:1331

#2  0x00008dc8 in function_div0last () at src/exchnd_test.c:281

#3  function_div03 () at src/exchnd_test.c:287

#4  function_div02 () at src/exchnd_test.c:292

#5  function_div01 (myvalue=0) at src/exchnd_test.c:298

#6  main (argc=<optimized out>, argv=<optimized out>) at src/exchnd_test.c:988

#7  0x76e652bc in __libc_start_main () from /lib/libc.so.6

#8  0x00009404 in _start () at ../ports/sysdeps/arm/start.S:124

 

As you can guess from these callstack, I’m working on ARM.

 

From what I can tel from the objdump, gcc has optimized the call in this example, but that doesn’t explain why we don’t see __libc_start_main (as we see it in other exception cases).

On all SIGFPE exception I saw until now, unw_step always stopped on __aeabi_ldiv0.

 

Any idea on what can happened there ?

 

Best regards

 

Frederic Berat

 

 

 

See below for some more information. I’m sorry in advance if a lot of things below are useless.

 

 

Application build command:

arm-none-linux-gnueabi-gcc -Wall -Wextra -Wformat -Wno-format-nonliteral -Wformat-security -Wformat-y2k -Werror -g -O3 -rdynamic -mtp=auto -mfloat-abi=softfp -mfpu=vfpv3-d16 -march=armv7-a -mtune=cortex-a9 -DG_BYTE_ORDER=G_LITTLE_ENDIAN -ffunction-sections -fdata-sections -funwind-  -o exchnd_test.o -c src/exchnd_test.c

 

libunwind configuration:

configure --build=x86_64-linux --host=arm-mel-linux-gnueabi --target=arm-mel-linux-gnueabi --prefix=/usr --exec_prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib/libunwind --datadir=/usr/share --sysconfdir=/etc --sharedstatedir=/com --localstatedir=/var --libdir=/usr/lib --includedir=/usr/include --oldincludedir=/usr/include --infodir=/usr/share/info --mandir=/usr/share/man --disable-silent-rules --disable-dependency-tracking --enable-minidebuginfo

 

Libunwund version: 1.1

 

--

I also tried with libunwind head and the following configuration and different UNW_ARM_UNWIND_METHOD env values:

 

configure --build=x86_64-linux --host=arm-mel-linux-gnueabi --target=arm-mel-linux-gnueabi --prefix=/usr --exec_prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib/libunwind --datadir=/usr/share --sysconfdir=/etc --sharedstatedir=/com --localstatedir=/var --libdir=/usr/lib --includedir=/usr/include --oldincludedir=/usr/include --infodir=/usr/share/info --mandir=/usr/share/man --disable-silent-rules --disable-dependency-tracking --enable-maintainer-mode --enable-debug --enable-debug-frame --enable-minidebuginfo

 

The result is the same.

--

 

Concerning the test application:

====== processor registers:

R0:  00000000 R1:  00000117 R2:  00000008 R3:  76f5f4c0 R4:  7e88bc58 R5:  00000000

R6:  000093d8 R7:  0000010c R8:  00000000 R9:  00000000 R10: 76f64000

FP:  00000000 IP:  76f23918 SP:  7e88acfc LR:  0000b108 PC:  76f2393c CPSR: 20000010

====== stack dump:

<7e88acfc> 00000000 00000000 00008dc8 00000000 ................

<7e88ad0c> 00000000 00000000 00000000 00000000 ................

--- Skip zeroed

<7e88b27c> 00000000 00000000 00000000 001356cc .............V..

<7e88b28c> 76eea000 7e88b2d8 76ee9e24 ffffffff ...v...~$..v....

<7e88b29c> 00000000 00000000 00000000 00000000 ................

--- Skip zeroed

<7e88b2bc> 00000000 00000000 0012d000 0012ce28 ............(...

<7e88b2cc> 0012ce28 00000000 00000005 00135000 (............P..

<7e88b2dc> 00138000 00137e24 0013a5a8 0012d000 ....$~..........

<7e88b2ec> 00000003 00000000 00000000 00000000 ................

<7e88b2fc> 00000000 00000000 00000000 00000000 ................

<7e88b30c> 00015000 00014b10 00014b10 7e88b60c .P...K...K.....~

<7e88b31c> 7e88b66c 7e88b4f4 7e88b52c 76f573f8 l..~...~,..~.s.v

<7e88b32c> 00000020 7e88b60c 7e88b37c 00000000  ......~|..~....

<7e88b33c> 00000000 00000000 00000000 00000000 ................

<7e88b34c> 00000000 7e88b388 00000003 00000000 .......~........

<7e88b35c> 76f61ba0 76f61ba0 76f471f0 76f64960 ...v...v.q.v`I.v

<7e88b36c> 007a33b8 00000000 00000000 00000000 .3z.............

<7e88b37c> 76f64058 00000003 76f61ba0 76eea000 address@hidden

<7e88b38c> 76f4310c 00000000 00000000 0000362e .1.v.........6..

<7e88b39c> 00362e6f 00362e6f 00362e6f 00000000 o.6.o.6.o.6.....

<7e88b3ac> 00000000 00000003 76f61658 0012d000 ........X..v....

<7e88b3bc> 00138e23 76eec5a8 76f3cdf0 00000000 #......v...v....

<7e88b3cc> 76dc3e8e 00000000 76f44774 7e88b390 .>.v....tG.v...~

<7e88b3dc> 00000003 00000000 76f16457 00000000 ........Wd.v....

<7e88b3ec> 76f44774 00000003 7e88b4f4 76ef8df7 tG.v.......~...v

<7e88b3fc> 73516240 00000001 6474e552 7e88b2c0 @bQs....R.td...~

<7e88b40c> 0013a5a8 76ef8df7 00000000 00000000 .......v........

<7e88b41c> 007a33b8 000081a4 00000001 00000000 .3z.............

<7e88b42c> 00000000 00000000 00000000 00000000 ................

<7e88b43c> 00000000 00131668 00000000 00001000 ....h...........

<7e88b44c> 00000000 00000990 00000000 5506b429 ............)..U

<7e88b45c> 34ef21f2 550063b9 00000000 5506b411 .!.4.c.U.......U

 

Sections:

Idx Name          Size      VMA       LMA       File off  Algn

  0 .interp       00000013  00008134  00008134  00000134  2**0

                  CONTENTS, ALLOC, LOAD, READONLY, DATA

  1 .note.ABI-tag 00000020  00008148  00008148  00000148  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, DATA

  2 .hash         00000148  00008168  00008168  00000168  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, DATA

  3 .dynsym       000002b0  000082b0  000082b0  000002b0  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, DATA

  4 .dynstr       000001e3  00008560  00008560  00000560  2**0

                  CONTENTS, ALLOC, LOAD, READONLY, DATA

  5 .gnu.version  00000056  00008744  00008744  00000744  2**1

                  CONTENTS, ALLOC, LOAD, READONLY, DATA

  6 .gnu.version_r 00000060  0000879c  0000879c  0000079c  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, DATA

  7 .rel.dyn      00000020  000087fc  000087fc  000007fc  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, DATA

  8 .rel.plt      00000110  0000881c  0000881c  0000081c  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, DATA

  9 .init         0000000c  0000892c  0000892c  0000092c  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, CODE

10 .plt          000001ac  00008938  00008938  00000938  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, CODE

11 .text         00002690  00008ae4  00008ae4  00000ae4  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, CODE

12 .fini         00000008  0000b174  0000b174  00003174  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, CODE

13 .rodata       00001db4  0000b17c  0000b17c  0000317c  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, DATA

14 .ARM.extab    00000060  0000cf30  0000cf30  00004f30  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, DATA

15 .ARM.exidx    000000f0  0000cf90  0000cf90  00004f90  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, DATA

16 .eh_frame     00000004  0000d080  0000d080  00005080  2**2

                  CONTENTS, ALLOC, LOAD, READONLY, DATA

17 .init_array   00000004  00015084  00015084  00005084  2**2

                  CONTENTS, ALLOC, LOAD, DATA

18 .fini_array   00000004  00015088  00015088  00005088  2**2

                  CONTENTS, ALLOC, LOAD, DATA

19 .jcr          00000004  0001508c  0001508c  0000508c  2**2

                  CONTENTS, ALLOC, LOAD, DATA

20 .dynamic      000000f8  00015090  00015090  00005090  2**2

                  CONTENTS, ALLOC, LOAD, DATA

21 .got          00000098  00015188  00015188  00005188  2**2

                  CONTENTS, ALLOC, LOAD, DATA

22 .data         000003c0  00015220  00015220  00005220  2**2

                  CONTENTS, ALLOC, LOAD, DATA

23 .bss          0002d778  000155e0  000155e0  000055e0  2**3

                  ALLOC

24 .comment      00000041  00000000  00000000  000055e0  2**0

                  CONTENTS, READONLY

25 .ARM.attributes 00000033  00000000  00000000  00005621  2**0

                  CONTENTS, READONLY

26 .debug_aranges 00000228  00000000  00000000  00005658  2**3

                  CONTENTS, READONLY, DEBUGGING

27 .debug_info   00004533  00000000  00000000  00005880  2**0

                  CONTENTS, READONLY, DEBUGGING

28 .debug_abbrev 00000bdc  00000000  00000000  00009db3  2**0

                  CONTENTS, READONLY, DEBUGGING

29 .debug_line   00001047  00000000  00000000  0000a98f  2**0

                  CONTENTS, READONLY, DEBUGGING

30 .debug_frame  000003fc  00000000  00000000  0000b9d8  2**2

                  CONTENTS, READONLY, DEBUGGING

31 .debug_str    000018ee  00000000  00000000  0000bdd4  2**0

                  CONTENTS, READONLY, DEBUGGING

32 .debug_loc    000014bb  00000000  00000000  0000d6c2  2**0

                  CONTENTS, READONLY, DEBUGGING

33 .debug_ranges 00000488  00000000  00000000  0000eb80  2**3

                  CONTENTS, READONLY, DEBUGGING

 

Contents of section .ARM.extab:

cf30 08b10181 b0b00084 00000000 08b10181  ................

cf40 b0b00084 00000000 08b10181 b0b00084  ................

cf50 00000000 08b10181 b0b003a9 00000000  ................

cf60 deb20181 b003a905 00000000 08b10181  ................

cf70 b0b003a9 00000000 82b20181 b0b0a907  ................

cf80 00000000 c6b20181 b0b0af06 00000000  ................

Contents of section .ARM.exidx:

cf90 54bbff7f f0ffff7f 40c4ff7f 01000000  address@hidden

cfa0 98c4ff7f 8cffff7f c8c4ff7f 90ffff7f  ................

cfb0 00c5ff7f b0b0a880 20c5ff7f 8cffff7f  ........ .......

cfc0 4cc5ff7f b0aa0780 d4c5ff7f b0ab0880  L...............

cfd0 9cc6ff7f b0b0a880 d4c6ff7f b003a880  ................

cfe0 30c7ff7f 70ffff7f 1cc8ff7f b003a880  0...p...........

cff0 80c8ff7f 03af0280 f8c9ff7f 64ffff7f  ............d...

d000 84caff7f b003a880 d4caff7f 60ffff7f  ............`...

d010 28cbff7f 64ffff7f 94cbff7f b0b0a880  (...d...........

d020 10ccff7f ab08b180 64ccff7f b0b0b080  ........d.......

d030 d4ccff7f ab08b180 24cfff7f b0b0ac80  ........$.......

d040 64d0ff7f ab08b180 0cd3ff7f b0b0a880  d...............

d050 64d3ff7f b0ad1c80 70d4ff7f b0af0a80  d.......p.......

d060 5cdeff7f 01000000 a4e0ff7f ad08b180  \...............

d070 00e1ff7f b0b0b080 fce0ff7f 01000000  ................

 

0000b0fc <__aeabi_idiv0>:

    b0fc:       e92d4002        push    {r1, lr}

    b100:       e3a00008        mov     r0, #8

    b104:       ebfff613        bl      8958 <_init+0x2c>

    b108:       e8bd8002        pop     {r1, pc}

 

0000aebc <__aeabi_idiv>:

    aebc:       e3510000        cmp     r1, #0

    aec0:       0a000081        beq     b0cc <.divsi3_skip_div0_test+0x208>

 

0000aec4 <.divsi3_skip_div0_test>:

    aec4:       e020c001        eor     ip, r0, r1

    aec8:       42611000        rsbmi   r1, r1, #0

    aecc:       e2512001        subs    r2, r1, #1

    aed0:       0a000070        beq     b098 <.divsi3_skip_div0_test+0x1d4>

    aed4:       e1b03000        movs    r3, r0

    aed8:       42603000        rsbmi   r3, r0, #0

    aedc:       e1530001        cmp     r3, r1

    aee0:       9a00006f        bls     b0a4 <.divsi3_skip_div0_test+0x1e0>

    aee4:       e1110002        tst     r1, r2

    aee8:       0a000071        beq     b0b4 <.divsi3_skip_div0_test+0x1f0>

    aeec:       e16f2f13        clz     r2, r3

    aef0:       e16f0f11        clz     r0, r1

    aef4:       e0402002        sub     r2, r0, r2

    aef8:       e272201f        rsbs    r2, r2, #31

    aefc:       10822082        addne   r2, r2, r2, lsl #1

    af00:       e3a00000        mov     r0, #0

    af04:       108ff102        addne   pc, pc, r2, lsl #2

    af08:       e1a00000        nop                     ; (mov r0, r0)

    af0c:       e1530f81        cmp     r3, r1, lsl #31

    af10:       e0a00000        adc     r0, r0, r0

    af14:       20433f81        subcs   r3, r3, r1, lsl #31

    af18:       e1530f01        cmp     r3, r1, lsl #30

    af1c:       e0a00000        adc     r0, r0, r0

    af20:       20433f01        subcs   r3, r3, r1, lsl #30

    af24:       e1530e81        cmp     r3, r1, lsl #29

    af28:       e0a00000        adc     r0, r0, r0

    af2c:       20433e81        subcs   r3, r3, r1, lsl #29

    af30:       e1530e01        cmp     r3, r1, lsl #28

    af34:       e0a00000        adc     r0, r0, r0

    af38:       20433e01        subcs   r3, r3, r1, lsl #28

    af3c:       e1530d81        cmp     r3, r1, lsl #27

    af40:       e0a00000        adc     r0, r0, r0

    af44:       20433d81        subcs   r3, r3, r1, lsl #27

    af48:       e1530d01        cmp     r3, r1, lsl #26

    af4c:       e0a00000        adc     r0, r0, r0

    af50:       20433d01        subcs   r3, r3, r1, lsl #26

    af54:       e1530c81        cmp     r3, r1, lsl #25

    af58:       e0a00000        adc     r0, r0, r0

    af5c:       20433c81        subcs   r3, r3, r1, lsl #25

    af60:       e1530c01        cmp     r3, r1, lsl #24

    af64:       e0a00000        adc     r0, r0, r0

    af68:       20433c01        subcs   r3, r3, r1, lsl #24

    af6c:       e1530b81        cmp     r3, r1, lsl #23

    af70:       e0a00000        adc     r0, r0, r0

    af74:       20433b81        subcs   r3, r3, r1, lsl #23

    af78:       e1530b01        cmp     r3, r1, lsl #22

    af7c:       e0a00000        adc     r0, r0, r0

    af80:       20433b01        subcs   r3, r3, r1, lsl #22

    af84:       e1530a81        cmp     r3, r1, lsl #21

    af88:       e0a00000        adc     r0, r0, r0

    af8c:       20433a81        subcs   r3, r3, r1, lsl #21

    af90:       e1530a01        cmp     r3, r1, lsl #20

    af94:       e0a00000        adc     r0, r0, r0

    af98:       20433a01        subcs   r3, r3, r1, lsl #20

    af9c:       e1530981        cmp     r3, r1, lsl #19

    afa0:       e0a00000        adc     r0, r0, r0

    afa4:       20433981        subcs   r3, r3, r1, lsl #19

    afa8:       e1530901        cmp     r3, r1, lsl #18

    afac:       e0a00000        adc     r0, r0, r0

    afb0:       20433901        subcs   r3, r3, r1, lsl #18

    afb4:       e1530881        cmp     r3, r1, lsl #17

    afb8:       e0a00000        adc     r0, r0, r0

    afbc:       20433881        subcs   r3, r3, r1, lsl #17

    afc0:       e1530801        cmp     r3, r1, lsl #16

    afc4:       e0a00000        adc     r0, r0, r0

    afc8:       20433801        subcs   r3, r3, r1, lsl #16

    afcc:       e1530781        cmp     r3, r1, lsl #15

    afd0:       e0a00000        adc     r0, r0, r0

    afd4:       20433781        subcs   r3, r3, r1, lsl #15

    afd8:       e1530701        cmp     r3, r1, lsl #14

    afdc:       e0a00000        adc     r0, r0, r0

    afe0:       20433701        subcs   r3, r3, r1, lsl #14

    afe4:       e1530681        cmp     r3, r1, lsl #13

    afe8:       e0a00000        adc     r0, r0, r0

    afec:       20433681        subcs   r3, r3, r1, lsl #13

    aff0:       e1530601        cmp     r3, r1, lsl #12

    aff4:       e0a00000        adc     r0, r0, r0

    aff8:       20433601        subcs   r3, r3, r1, lsl #12

    affc:       e1530581        cmp     r3, r1, lsl #11

    b000:       e0a00000        adc     r0, r0, r0

    b004:       20433581        subcs   r3, r3, r1, lsl #11

    b008:       e1530501        cmp     r3, r1, lsl #10

    b00c:       e0a00000        adc     r0, r0, r0

    b010:       20433501        subcs   r3, r3, r1, lsl #10

    b014:       e1530481        cmp     r3, r1, lsl #9

    b018:       e0a00000        adc     r0, r0, r0

    b01c:       20433481        subcs   r3, r3, r1, lsl #9

    b020:       e1530401        cmp     r3, r1, lsl #8

    b024:       e0a00000        adc     r0, r0, r0

    b028:       20433401        subcs   r3, r3, r1, lsl #8

    b02c:       e1530381        cmp     r3, r1, lsl #7

    b030:       e0a00000        adc     r0, r0, r0

    b034:       20433381        subcs   r3, r3, r1, lsl #7

    b038:       e1530301        cmp     r3, r1, lsl #6

    b03c:       e0a00000        adc     r0, r0, r0

    b040:       20433301        subcs   r3, r3, r1, lsl #6

    b044:       e1530281        cmp     r3, r1, lsl #5

    b048:       e0a00000        adc     r0, r0, r0

    b04c:       20433281        subcs   r3, r3, r1, lsl #5

    b050:       e1530201        cmp     r3, r1, lsl #4

    b054:       e0a00000        adc     r0, r0, r0

    b058:       20433201        subcs   r3, r3, r1, lsl #4

    b05c:       e1530181        cmp     r3, r1, lsl #3

    b060:       e0a00000        adc     r0, r0, r0

    b064:       20433181        subcs   r3, r3, r1, lsl #3

    b068:       e1530101        cmp     r3, r1, lsl #2

    b06c:       e0a00000        adc     r0, r0, r0

    b070:       20433101        subcs   r3, r3, r1, lsl #2

    b074:       e1530081        cmp     r3, r1, lsl #1

    b078:       e0a00000        adc     r0, r0, r0

    b07c:       20433081        subcs   r3, r3, r1, lsl #1

    b080:       e1530001        cmp     r3, r1

    b084:       e0a00000        adc     r0, r0, r0

    b088:       20433001        subcs   r3, r3, r1

    b08c:       e35c0000        cmp     ip, #0

    b090:       42600000        rsbmi   r0, r0, #0

    b094:       e12fff1e        bx      lr

    b098:       e13c0000        teq     ip, r0

    b09c:       42600000        rsbmi   r0, r0, #0

    b0a0:       e12fff1e        bx      lr

    b0a4:       33a00000        movcc   r0, #0

    b0a8:       01a00fcc        asreq   r0, ip, #31

    b0ac:       03800001        orreq   r0, r0, #1

    b0b0:       e12fff1e        bx      lr

    b0b4:       e16f2f11        clz     r2, r1

    b0b8:       e262201f        rsb     r2, r2, #31

    b0bc:       e35c0000        cmp     ip, #0

    b0c0:       e1a00233        lsr     r0, r3, r2

    b0c4:       42600000        rsbmi   r0, r0, #0

    b0c8:       e12fff1e        bx      lr

    b0cc:       e3500000        cmp     r0, #0

    b0d0:       c3e00102        mvngt   r0, #-2147483648        ; 0x80000000

    b0d4:       b3a00102        movlt   r0, #-2147483648        ; 0x80000000

    b0d8:       ea000007        b       b0fc <__aeabi_idiv0>

 

00008ae4 <main>:

[…]

    8dbc:       e3a01000        mov     r1, #0

    8dc0:       e3a00001        mov     r0, #1

    8dc4:       eb00083c        bl      aebc <__aeabi_idiv>

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]