Skip to contentSkip to conversation

bus error on sparc64 running type-preservation test

DISCUSSION Tom Turelinckx 2 participants 5 messages Apr 13, 2020 – Apr 21, 2020 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

Hi,

Since v1.4.7 DTC FTBFS on Debian sparc64 because of a bus error when running the type-preservation.dts test.

Build logs are available here:

https://buildd.debian.org/status/logs.php?pkg=device-tree-compiler&arch=sparc64

It may be an alignment issue introduced in this commit:

https://github.com/dgibson/dtc/commit/32b9c61307629ac76c6ac0bead6f926d579b3d2c

I have no idea how to fix this, but the following gdb backtrace (from v1.6.0) may help someone else:

Reading symbols from dtc...
(gdb) r -I dts -O dts -o tests/type-preservation.dts.test.dts tests/type-preservation.dts
Starting program: /build/device-tree-compiler-1.6.0/dtc -I dts -O dts -o tests/type-preservation.dts.test.dts tests/type-preservation.dts

Program received signal SIGBUS, Bus error.
0x0000010000010600 in write_propval_int (f=0x10000120300, p=0x100001268af "", len=<optimized out>, width=4)

    at treesource.c:108
108                     switch (width) {
(gdb) bt
#0  0x0000010000010600 in write_propval_int (f=0x10000120300, p=0x100001268af "", len=<optimized out>, width=4)
    at treesource.c:108
#1  0x0000010000010c6c in write_propval (prop=0x100001268e0, f=0x10000120300) at treesource.c:251
#2  write_tree_source_node (f=0x10000120300, tree=0x10000126960, level=<optimized out>) at treesource.c:310
#3  0x0000010000010c10 in write_tree_source_node (f=0x10000120300, tree=0x10000126a50, level=<optimized out>)
    at treesource.c:314
#4  0x0000010000010c10 in write_tree_source_node (f=0x10000120300, tree=0x10000126b40, level=<optimized out>)
    at treesource.c:314
#5  0x0000010000010c10 in write_tree_source_node (f=0x10000120300, tree=0x10000126c30, level=<optimized out>)
    at treesource.c:314

#6 0x00000100000054f4 in main (argc=<optimized out>, argv=<optimized out>) at dtc.c:351

If somebody has a suggestion for a patch, I can test it on Debian sparc64. I'm not subscribed to this list.

Best regards,
Tom Turelinckx

#1 lore raw
Quoted 1 line · I wrote:

I have no idea how to fix this, but the following gdb backtrace (from v1.6.0) may help someone else:

With -O0:

Reading symbols from dtc...
(gdb) r -I dts -O dts -o tests/type-preservation.dts.test.dts tests/type-preservation.dts
Starting program: /build/device-tree-compiler-1.6.0/dtc -I dts -O dts -o tests/type-preservation.dts.test.dts tests/type-preservation.dts

Program received signal SIGBUS, Bus error.
0x0000010000017f2c in write_propval_int (f=0x1000012e300, p=0x100001348af "", len=4, width=4) at treesource.c:116
116 fprintf(f, "0x%02"PRIx32, fdt32_to_cpu(*(const fdt32_t*)p));
(gdb) bt

#0  0x0000010000017f2c in write_propval_int (f=0x1000012e300, p=0x100001348af "", len=4, width=4) at treesource.c:116
#1  0x0000010000018704 in write_propval (f=0x1000012e300, prop=0x100001348e0) at treesource.c:251
#2  0x0000010000018b8c in write_tree_source_node (f=0x1000012e300, tree=0x10000134960, level=3) at treesource.c:310
#3  0x0000010000018c04 in write_tree_source_node (f=0x1000012e300, tree=0x10000134a30, level=2) at treesource.c:314
#4  0x0000010000018c04 in write_tree_source_node (f=0x1000012e300, tree=0x10000134b20, level=1) at treesource.c:314
#5  0x0000010000018c04 in write_tree_source_node (f=0x1000012e300, tree=0x10000134c10, level=0) at treesource.c:314
#6  0x0000010000018e28 in dt_to_source (f=0x1000012e300, dti=0x100001325c0) at treesource.c:344
#7  0x0000010000005f1c in main (argc=8, argv=0x7fefffff528) at dtc.c:351

Tom

#2 lore raw
Quoted 14 lines · Tom Turelinckx
Quoted 1 line · I wrote:

I have no idea how to fix this, but the following gdb backtrace (from v1.6.0) may help someone else:

With -O0:

Reading symbols from dtc...
(gdb) r -I dts -O dts -o tests/type-preservation.dts.test.dts tests/type-preservation.dts
Starting program: /build/device-tree-compiler-1.6.0/dtc -I dts -O dts -o tests/type-preservation.dts.test.dts tests/type-preservation.dts

Program received signal SIGBUS, Bus error.
0x0000010000017f2c in write_propval_int (f=0x1000012e300, p=0x100001348af "", len=4, width=4) at treesource.c:116
116 fprintf(f, "0x%02"PRIx32, fdt32_to_cpu(*(const fdt32_t*)p));
(gdb) bt

Quoted 8 lines
#0  0x0000010000017f2c in write_propval_int (f=0x1000012e300, p=0x100001348af "", len=4, width=4) at treesource.c:116
#1  0x0000010000018704 in write_propval (f=0x1000012e300, prop=0x100001348e0) at treesource.c:251
#2  0x0000010000018b8c in write_tree_source_node (f=0x1000012e300, tree=0x10000134960, level=3) at treesource.c:310
#3  0x0000010000018c04 in write_tree_source_node (f=0x1000012e300, tree=0x10000134a30, level=2) at treesource.c:314
#4  0x0000010000018c04 in write_tree_source_node (f=0x1000012e300, tree=0x10000134b20, level=1) at treesource.c:314
#5  0x0000010000018c04 in write_tree_source_node (f=0x1000012e300, tree=0x10000134c10, level=0) at treesource.c:314
#6  0x0000010000018e28 in dt_to_source (f=0x1000012e300, dti=0x100001325c0) at treesource.c:344
#7  0x0000010000005f1c in main (argc=8, argv=0x7fefffff528) at dtc.c:351

Yeah, it definitely looks like an alignment problem. The 'p' parameter to write_propval_int() is not 4-byte aligned, but width == 4, which means it will attempt to read from p as a 32-bit integer pointer.

Some grepping also suggests several other places in dtc which could suffer from the same problem, though I suspect they're less likely to trigger.

I've just merged and pushed a change which I think will fix this to the master branch. Could you build and test that please?

If you can make a minimal testcase which triggers this problem and submit it as an addition to the dtc testsuite, that would be terrific.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Hi,

Quoted 2 lines · David Gibson

I've just merged and pushed a change which I think will fix this to the master branch. Could you build and test that please?

It seems to work, thanks!

I've verified on debian sparc64 that make and make check succeed when I checkout b28464a, while make check fails with bus error when I checkout 87a656a.

I've also verified that the debian src package version 1.6.0-1 builds successfully on sparc64 with patch b28464a applied locally, and that the same package with the same patch applied still builds successfully on amd64. Those are the only archs I have access to.

Quoted 2 lines

If you can make a minimal testcase which triggers this problem and submit it as an addition to the dtc testsuite, that would be terrific.

I have limited experience with C development, and zero experience with alignment issues, DTC or its test suite, so I can't be of much help here...

Best regards,
Tom

A message that is not in the archive (sent off-list or not yet received): 4c0be4b4-7f6e-4612-af7b-dfffb400597a-jFIJ+Wc5/Vo7lZ9V/[email protected]

#6 lore raw
Quoted 10 lines · Tom Turelinckx

Hi,

Quoted 2 lines · David Gibson

I've just merged and pushed a change which I think will fix this to the master branch. Could you build and test that please?

It seems to work, thanks!

I've verified on debian sparc64 that make and make check succeed when I checkout b28464a, while make check fails with bus error when I checkout 87a656a.

Quoted 8 lines

I've also verified that the debian src package version 1.6.0-1 builds successfully on sparc64 with patch b28464a applied locally, and that the same package with the same patch applied still builds successfully on amd64. Those are the only archs I have access to.

Quoted 2 lines

If you can make a minimal testcase which triggers this problem and submit it as an addition to the dtc testsuite, that would be terrific.

I have limited experience with C development, and zero experience with alignment issues, DTC or its test suite, so I can't be of much help here...

The relevant part of the test suite is nearly all shell. But I realized this isn't actually relevant anyway. I thought the problem was that we didn't have a test which exercised this unaligned case - but you said it tripped on the type preservation test, so there is a testcase there already. I assume it wasn't caught before just because sparc64 is more sensitive to misaligned loads than on the archs I generally build for. I would have thought ARM would have caught it, but apparently not. I can't think of any easy way to extend the testsuite to handle that, so there's not really anything to be done here.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson