tenstorrent / tt-metal

:metal: TT-NN operator library, and TT-Metalium low level kernel programming model.
Apache License 2.0
458 stars 67 forks source link

Disassembler crashes while disassembling. #14398

Open amahmudTT opened 2 days ago

amahmudTT commented 2 days ago

Describe the bug Branch : https://github.com/tenstorrent/tt-metal/compare/main...amahmud/fp32_perf Test case : tests/tt_metal/tt_metal/test_eltwise_add.cpp

This test case has empty reader and writer, it will compile and theoretically should work. But when we built the files and tried to disassemble the trisc0/1/2.elf files, it shows the disassembly but crashes in the end saying segmentation fault. So piping the output to a file is problematic.

To Reproduce

  1. Checkout the branch.
  2. Compile the C++ tests
  3. Run the test test_eltwise_add , it should be in tt-metal/build_Release/test/tt_metal
  4. Try to disassemble the trisc.0/1/2 files which should be in a subfolder in tt-metal/built folder My disassembly command was as follows : $tt_dir/tt_metal/third_party/sfpi/compiler/bin/riscv32-unknown-elf-objdump -D -S -t -g -C

The disassembler should crash with Segmentation Fault message.

environment information:

Additional context This test case is unique as the readers and writers are empty. I managed to get the assembly output to a file using linux script command. Hence the ^M

Screenshot 2024-10-28 at 5 18 17 PM

nathan-TT commented 22 hours ago

Is there a reason you're using -D rather than -d (disassembling all sections, rather than just executable ones)

amahmudTT commented 22 hours ago

Is there a reason you're using -D rather than -d (disassembling all sections, rather than just executable ones)

No, I think it was a mistake in my part

nathan-TT commented 22 hours ago

ok, use '-d' the crash is happening because the section (.comment) is not an integral number of instructions. Here's a smaller reproducer:

    .text
        lui a0,0x12345
        addi a0,a0,0x678
    .byte 2 ;; delete to remove crash
tt_metal/third_party/sfpi/compiler/bin/riscv32-unknown-elf-as -o asm.o asm.s
tt_metal/third_party/sfpi/compiler/bin/riscv32-unknown-elf-objdump -d asm.o

(because this is .text it'll crash with -d)

amahmudTT commented 22 hours ago

You meant crash with -D and not -d ?

nathan-TT commented 22 hours ago

no, that shorter example is an oddly-sized executable section, which both -d and -D attempt to disassemble

amahmudTT commented 22 hours ago

Ok, so is it still a bug then ? Or did I just use the wrong command ?

nathan-TT commented 22 hours ago

it is still a bug, but won't normally affect things -- use -d and usually text sections are integral numbers of instructions

amahmudTT commented 22 hours ago

ok