libgimbal icon indicating copy to clipboard operation
libgimbal copied to clipboard

[Bug] Unaligned GblTestFixture/GblPrivateData

Open suicvne opened this issue 8 months ago • 1 comments

Found an issue with unaligned memory access on Dreamcast for the unit tests.

When creating a test fixture with:

GBL_TEST_FIXTURE {
    char dummy;
};

The Dreamcast will shit itself upon creation of the GblTestFixture instance spewing out event code 0x100 which Falco tracked down to represent an "unaligned memory write".

The output from dc-tool-ip:

KallistiOS Git revision 34f7e943-dirty:
  Fri May 31 23:59:48 EDT 2024
  [email protected]:/opt/toolchains/dc/kos
  sh-elf-gcc (GCC) 14.1.0
thd: pre-emption enabled, HZ=100
maple: active drivers:
    Dreameye (Camera): Camera
    Sound Input Peripheral: Microphone
    PuruPuru (Vibration) Pack: JumpPack
    VMU Driver: Clock, LCD, MemoryCard
    Mouse Driver: Mouse
    Keyboard Driver: Keyboard
    Controller Driver: Controller
    Lightgun: LightGun
  DMA Buffer at ac4509e0
vid_set_mode: 640x480 VGA with 1 framebuffers.
dc-load console support enabled
maple: attached devices:
  A0: Dreamcast Controller          (01000000: Controller)

* =========== Cascade Information ===========
*   Version:      0.3.0
*   Git Hash:     
* =========== Cascade Information ===========
* pScenario: 0x8c469144
* Enqueue Central Dispatch Test
* Enqueue Logging Test
Unhandled exception: PC 8c2296b0, code 1, evt 0100
 R0-R7: 00000001 00000000 8cfff8dc 0000003f 00000000 00000000 00000001 00000000
 R8-R15: 8cfff860 8c471398 8c471300 8c47141d 8cfff91c 00000000 8cfff954 8cfff854
 SR 40000000 PR 8c22980c
-------- Stack Trace (innermost first) ---------
   8cfff95c
   (invalid frame pointer)
-------------- End Stack Trace -----------------
kernel panic: unhandled IRQ/Exception
arch: aborting the system

Fix on my code was to do this:

GBL_TEST_FIXTURE {
    char dummy[4];
};

We tracked down where in the code the problem was happening and found code was able to proceed further once this was fixed.

suicvne avatar Jun 01 '24 04:06 suicvne