Bug 2899

Summary: [ARM] general alignment error
Product: Busybox Reporter: Karsten Jeppesen <kjp>
Component: Standard ComplianceAssignee: unassigned
Status: RESOLVED WONTFIX    
Severity: critical CC: busybox-cvs
Priority: P5    
Version: 1.17.x   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: Target:
Build:

Description Karsten Jeppesen 2010-12-08 08:45:41 UTC
THIS PERTAINS TO THE ARM PLATFORM.
(my system: ARM9263)

The ARM cpu require non-byte primals (16,32,64bit) to be on specific boundaries.
/proc/cpu/alignment shows that alignment errors occur:
[SKOV]\$ cat /proc/cpu/alignment
User:           1906
System:         0
Skipped:        0
Half:           0
Word:           16
DWord:          0
Multi:          0
User faults:    3 (fixup+warn)
[SKOV]\$ cat /proc/cpu/alignment
User:           4574
System:         0
Skipped:        0
Half:           0
Word:           2684
DWord:          0
Multi:          0
User faults:    3 (fixup+warn)

To the best of my abilities it is busybox causing this. Dmesg says:
grep (2283) PC=0x4000ab48 Instr=0xe7951002 Address=0x40140b33 FSR 0x001
ash (2285) PC=0x4000ab48 Instr=0xe7951002 Address=0x40140b33 FSR 0x001
scp (2286) PC=0x4000ab48 Instr=0xe7951002 Address=0x40154b33 FSR 0x001
dmesg (2288) PC=0x4000ab54 Instr=0xe7851002 Address=0x40140b33 FSR 0x801

BTW: Can I help by pinpointing the place where it happens, and if so then: How do I get gdb to show the source line based on the above shown dmesg output?

Sincerely,
Dr. Karsten Jeppesen
Comment 1 Denys Vlasenko 2010-12-29 05:55:50 UTC
You can find out which function contains unaligned access this way, if you have build tree, not just busybox binary built by someone else.

Use busybox_unstripped binary from the build tree:

# gdb busybox_unstripped
GNU gdb 5.2
Copyright 2002 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 "i686-pc-linux-gnu"...
(gdb) disassemble 0x8049b71
                  ^^^^^^^^^ use PC value here.


Dump of assembler code for function xmalloc_readlink_or_warn:
0x8049b46 <xmalloc_readlink_or_warn>:   push   %esi
0x8049b47 <xmalloc_readlink_or_warn+1>: push   %ebx
0x8049b48 <xmalloc_readlink_or_warn+2>: mov    %eax,%ebx
0x8049b4a <xmalloc_readlink_or_warn+4>: call   0x8049b01 <xmalloc_readlink>
0x8049b4f <xmalloc_readlink_or_warn+9>: mov    %eax,%esi
0x8049b51 <xmalloc_readlink_or_warn+11>:        test   %eax,%eax
0x8049b53 <xmalloc_readlink_or_warn+13>:        jne    0x8049b7e <xmalloc_readlink_or_warn+56>
0x8049b55 <xmalloc_readlink_or_warn+15>:        mov    0x812705c,%eax
0x8049b5a <xmalloc_readlink_or_warn+20>:        mov    (%eax),%eax
0x8049b5c <xmalloc_readlink_or_warn+22>:        mov    $0x8104fe7,%edx
0x8049b61 <xmalloc_readlink_or_warn+27>:        cmp    $0x16,%eax
0x8049b64 <xmalloc_readlink_or_warn+30>:        je     0x8049b6f <xmalloc_readlink_or_warn+41>
0x8049b66 <xmalloc_readlink_or_warn+32>:        push   %eax
0x8049b67 <xmalloc_readlink_or_warn+33>:        call   0x80eca20 <strerror>
0x8049b6c <xmalloc_readlink_or_warn+38>:        mov    %eax,%edx
0x8049b6e <xmalloc_readlink_or_warn+40>:        pop    %ecx
0x8049b6f <xmalloc_readlink_or_warn+41>:        push   %edx
0x8049b70 <xmalloc_readlink_or_warn+42>:        push   %ebx
0x8049b71 <xmalloc_readlink_or_warn+43>:        push   $0x8104ff5
0x8049b76 <xmalloc_readlink_or_warn+48>:        call   0x8048f94 <bb_error_msg>
0x8049b7b <xmalloc_readlink_or_warn+53>:        add    $0xc,%esp
0x8049b7e <xmalloc_readlink_or_warn+56>:        mov    %esi,%eax
0x8049b80 <xmalloc_readlink_or_warn+58>:        pop    %ebx
0x8049b81 <xmalloc_readlink_or_warn+59>:        pop    %esi
0x8049b82 <xmalloc_readlink_or_warn+60>:        ret
End of assembler dump.


Then find the source file where the function in question is defined. In this example, it's xmalloc_readlink_or_warn and it is defined in libbb/xreadlink.c.

Then, run 

make libbb/xreadlink.s

in the build tree, and attach resulting .s file to this bug.

Repeat for every PC value where alignment fault is reported.
Comment 2 Denys Vlasenko 2011-02-07 13:41:43 UTC
Insufficient information to debug, closing. Reopen if you have more data.