dougallj / applegpu

Apple G13 GPU architecture docs and tools
BSD 3-Clause "New" or "Revised" License
552 stars 41 forks source link

AssertionError during disassembly #61

Open gip opened 5 months ago

gip commented 5 months ago

While using tinygrad debug mode I ran into this crash during apple gpu disassembly.

To repro: python3 compiler_explorer.py tmp_p36do0r triggers an assertion error at https://github.com/dougallj/applegpu/blob/main/applegpu.py#L1958

File: applegpu_assert_error_tmp_p36do0r.zip

 108: 0000                 <disassembly failed>
Traceback (most recent call last):
  File "/Users/gilles/gip/LLAMA/tinygrad/extra/disassemblers/applegpu/compiler_explorer.py", line 69, in <module>
    disassemble.disassemble(data, code_offset=code_offset)
  File "/Users/gilles/gip/LLAMA/tinygrad/extra/disassemblers/applegpu/disassemble.py", line 28, in disassemble
    asm = str(o.disassemble(n, pc = p + code_offset))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gilles/gip/LLAMA/tinygrad/extra/disassemblers/applegpu/applegpu.py", line 680, in disassemble
    operands = self.decode_operands(n)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gilles/gip/LLAMA/tinygrad/extra/disassemblers/applegpu/applegpu.py", line 647, in decode_operands
    return self.fields_to_operands(fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gilles/gip/LLAMA/tinygrad/extra/disassemblers/applegpu/applegpu.py", line 652, in fields_to_operands
    ordered_operands.append(o.decode(fields))
                            ^^^^^^^^^^^^^^^^
  File "/Users/gilles/gip/LLAMA/tinygrad/extra/disassemblers/applegpu/applegpu.py", line 1965, in decode
    return self.decode_impl(fields, allow64=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/gilles/gip/LLAMA/tinygrad/extra/disassemblers/applegpu/applegpu.py", line 1958, in decode_impl
    assert (value & 1) == 0
           ^^^^^^^^^^^^^^^^
AssertionError