New issue
Advanced search Search tips

Issue 739958 link

Starred by 2 users

Issue metadata

Status: Verified
Owner:
Closed: Jul 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

mkfs.ntfs crashes on ARM device when built with clang

Project Member Reported by benchan@chromium.org, Jul 6 2017

Issue description

mkfs.ntfs (from sys-fs/ntfs3g) crashes on arm (but not amd64) with a weird SIGBUS when it's compiled with clang (but not with gcc). The same executable doesn't crash when running under valgrind though.

Operating system: Linux
                  0.0.0 Linux 4.4.70-10482-g68a52822444c5 #1 SMP PREEMPT Thu Jul 6 14:50:28 PDT 2017 aarch64
CPU: arm
     ARMv1 ARM part(0x4100d0b0) features: half,thumb,fastmult,vfpv2,edsp,neon,vfpv3,tls,vfpv4,idiva,idivt
     6 CPUs

GPU: UNKNOWN

Crash reason:  SIGBUS
Crash address: 0x0
Process uptime: not available

Thread 0 (crashed)
 0  mkntfs + 0x1a7c
     r0 = 0x00000000    r1 = 0x00000005    r2 = 0xba2c1091    r3 = 0xba2c1095
     r4 = 0x00000001    r5 = 0x10000000    r6 = 0x00000220    r7 = 0xffd67f60
     r8 = 0x00000002    r9 = 0x001f01ff   r10 = 0x10000006   r12 = 0x00000018
     fp = 0x00000000    sp = 0xffd67f48    lr = 0x00000020    pc = 0xba2afa7c
    Found by: given as instruction pointer in context
 1  mkntfs + 0x581d
     sp = 0xffd67f68    pc = 0xba2b381f
    Found by: stack scanning
 2  libc-2.23.so!__sbrk [sbrk.c : 58 + 0x5]
     sp = 0xffd67f78    pc = 0xec14f1bf
    Found by: stack scanning
 3  libc-2.23.so!__malloc_info [malloc.c : 5141 + 0x4d]
     sp = 0xffd67f7c    pc = 0xec111049
    Found by: stack scanning
 4  libc-2.23.so!__default_morecore [morecore.c : 47 + 0x3]
     sp = 0xffd67f90    pc = 0xec111051
    Found by: stack scanning
 5  libc-2.23.so!sysmalloc [malloc.c : 2482 + 0x11]
     sp = 0xffd67f98    pc = 0xec10d309
    Found by: stack scanning
 6  libc-2.23.so!__libc_malloc [malloc.c : 2911 + 0x7]
     sp = 0xffd67fc8    pc = 0xec10f353
    Found by: stack scanning
 7  libc-2.23.so!__rpc_thread_destroy + 0x13755
     sp = 0xffd6804c    pc = 0xec18e624
    Found by: stack scanning
 8  mkntfs + 0x473f
     sp = 0xffd680c0    pc = 0xba2b2741
    Found by: stack scanning
 9  mkntfs + 0xfb7c
     sp = 0xffd680c8    pc = 0xba2bdb7e
    Found by: stack scanning

Loaded modules:
0xba2ae000 - 0xba2befff  mkntfs  ???  (main)  (WARNING: No symbols, mkntfs, E87ED02DFC6D2B86A26C560F9280C7CF0)
0xec0b8000 - 0xec195fff  libc-2.23.so  ???  (WARNING: Corrupt symbols, libc-2.23.so, 716FC8FFE9105347F387FC80D5F11A380)
0xec19e000 - 0xec1d3fff  libntfs-3g.so.88.0.0  ???
0xec1e3000 - 0xec1fbfff  ld-2.23.so  ???
 
Do we want to add the toolchain folks here?
Cc: llozano@chromium.org
Labels: Build-Toolchain
SIGBUS most likely is related to unaligned memory access. Is it possible to find the source line corresponding to the crash?
I also suspected that the issue could be related to unaligned memory access. However, when I debugged the code, the crash site didn't seem to be stable and shifted around. The crash didn't happen if I ran the program under valgrind. I did notice a few sites with potential unaligned access in the code by skimming through the code.

Do we expect any difference between gcc and clang (and/or the compiler options we use) w.r.t. unaligned memory access (e.g. -mstrict-access, -munaligned-access, etc)?
none that I can think of the top of my head. Someone mentioned a difference with pragma  packed?

it wouuld be weird that the crash site would shift around. 
Can you compile with +O1 or +O0 and see if the problem reproduces? 
We could use the bisect tool to triage this.

Is the priority set correctly?
Project Member

Comment 7 by bugdroid1@chromium.org, Jul 7 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/d89a7ead2b35514b1c8bae0fe226fc54ea606a91

commit d89a7ead2b35514b1c8bae0fe226fc54ea606a91
Author: Ben Chan <benchan@chromium.org>
Date: Fri Jul 07 07:57:18 2017

sys-fs/ntfs3g: compile with gcc

mkfs.ntfs crashes on arm when it's compiled with clang. This CL
temporarily forces ntfs3g to be compiled with gcc.

BUG= chromium:739958 
TEST=Run platform_CrosDisksFilesystem autotest on amd64 and arm devices.

Change-Id: I2b150844ac874225937f1d0e0e139220db0304a1
Reviewed-on: https://chromium-review.googlesource.com/562590
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>

[modify] https://crrev.com/d89a7ead2b35514b1c8bae0fe226fc54ea606a91/sys-fs/ntfs3g/ntfs3g-2017.3.23-r2.ebuild

Project Member

Comment 8 by bugdroid1@chromium.org, Jul 7 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/181fc831f7bea8668bf4cd7cfbcb630781911e5e

commit 181fc831f7bea8668bf4cd7cfbcb630781911e5e
Author: Ben Chan <benchan@chromium.org>
Date: Fri Jul 07 22:04:16 2017

sys-fs/ntfs: uprev ebuild for CL:562590

BUG= chromium:739958 
TEST=emerge-$BOARD ntfs3g

Change-Id: Ibdbfbd62479105c837ee4b3e3b3bf426fa4b86f5
Reviewed-on: https://chromium-review.googlesource.com/563546
Commit-Ready: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>

[rename] https://crrev.com/181fc831f7bea8668bf4cd7cfbcb630781911e5e/sys-fs/ntfs3g/ntfs3g-2017.3.23-r3.ebuild

Ben Chan, How can I reproduce the problem. Can you share the command line used?
the platform_CrosDisksFilesystem Autotest test will trigger this bug. You can find the relevant mkfs.ntfs line in the logs from the test.
Owner: manojgupta@chromium.org
Project Member

Comment 13 by bugdroid1@chromium.org, Jul 13 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/4e9e7fe1aba0e612fbe038a11afce2e0f6c95a7c

commit 4e9e7fe1aba0e612fbe038a11afce2e0f6c95a7c
Author: Manoj Gupta <manojgupta@google.com>
Date: Thu Jul 13 18:44:39 2017

sys-fs/ntfs3g: Fix crash in mkfs.ntfs on ARM when built with clang.

Mark internal types used in ntfs packets as unaligned to avoid crashes.
These types are used everywhere in packed structs and the source code
freely takes addresses of these types. Clang generated code crashes
because clang assumed that the types are aligned.

BUG= chromium:739958 
TEST=platform_CrosDisksFilesystem test passed on kevin and caroline.

Change-Id: I1d1ab42c8b84a6b0fcc43b760419f8c0a87fd4d5
Reviewed-on: https://chromium-review.googlesource.com/568779
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>

[rename] https://crrev.com/4e9e7fe1aba0e612fbe038a11afce2e0f6c95a7c/sys-fs/ntfs3g/ntfs3g-2017.3.23-r4.ebuild
[add] https://crrev.com/4e9e7fe1aba0e612fbe038a11afce2e0f6c95a7c/sys-fs/ntfs3g/files/ntfs3g-2017.3.23-unaligned-types.patch

Owner: benchan@chromium.org
benchan@ please verify that the crash is fixed.
Thanks Manoj!
Status: Fixed (was: Assigned)
Status: Verified (was: Fixed)
Closing. Please reopen it if its not fixed. Thanks!

Sign in to add a comment