Menu

#3631 misaligned access in codegen for mos6502 port

closed-fixed
None
MOS6502
5
2023-12-24
2023-08-03
No

Using sanitizers, I found a misaligned access in code generation of the mos6502 port:

gen.c:578:19: runtime error: member access within misaligned address 0x5651ea9baf51 for type 'struct reg_info', which requires 8 byte alignment

Related

Bugs: #3630

Discussion

  • Gabriele Gorla

    Gabriele Gorla - 2023-11-29

    I just did a clean build using GCC 12 from debian using the sanitizer flags and run the regression but I cannot reproduce the issue.
    Are there any specific steps to reproduce the issue?

     
    • Philipp Klaus Krause

      I just reproduced the issue on my Debian GNU/Linux testing system on amd64 using GCC 13.2.0.

      SDCC was configured via:

      ./configure CC="gcc -fsanitize=undefined" CXX="g++ -fsanitize=undefined" LDFLAGS="-fsanitize=undefined"
      

      And I see the error message when compiling the library:

      /home/philipp/sdcc-trunk/sdcc/bin/sdcc -I./../../include -I. --std-c23  -mmos6502 --max-allocs-per-node 25000 --opt-code-speed -c atomic_flag_test_and_set.c -o atomic_flag_test_and_set.rel
      test . = . || cp __sdcc_indirect_jsr.s .
      ../../../bin/sdas6500 -plosgff __sdcc_indirect_jsr.s
      test . = . || rm __sdcc_indirect_jsr.s
      /home/philipp/sdcc-trunk/sdcc/bin/sdcc -I./../../include -I. --std-c23  -mmos6502 --max-allocs-per-node 25000 --opt-code-speed -c ../_atof.c -o _atof.rel
      gen.c:582:19: runtime error: member access within misaligned address 0x5627133b7181 for type 'struct reg_info', which requires 8 byte alignment
      0x5627133b7181: note: pointer points here
       00 00 00  00 5f 61 74 6f 66 5f 69  65 78 70 5f 31 30 30 30  30 5f 35 37 00 00 00 00  00 00 00 00 00
                    ^
      
       

      Last edit: Philipp Klaus Krause 2023-11-29
  • Gabriele Gorla

    Gabriele Gorla - 2023-11-29
    • assigned_to: Gabriele Gorla
     
  • Gabriele Gorla

    Gabriele Gorla - 2023-12-03

    yep, it was a bad pointer.
    Code was dereferencing an AOP register before checking if it was actually a register.
    should be fixed with [r14497]

     

    Related

    Commit: [r14497]


    Last edit: Gabriele Gorla 2023-12-17
  • Gabriele Gorla

    Gabriele Gorla - 2023-12-03
    • status: open --> pending-fixed
     
  • Gabriele Gorla

    Gabriele Gorla - 2023-12-24
    • status: pending-fixed --> closed
     
  • Gabriele Gorla

    Gabriele Gorla - 2023-12-24
    • status: closed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB