Skip to content

DebugMemWrite8 segfaults when debugger isnt properly setup #1152

@Mai-Lapyst

Description

@Mai-Lapyst

When trying to call DebugMemWrite8 before setting up the debugger correctly via init_debugger, the function dosnt return M64ERR_INVALID_STATE like other functions like DebugStep, but rather segfaults when trying to read the instruction at the pc in cp0_update_count.

Example code:

if (CoreStartup( coreApiVersion, NULL, NULL, NULL, NULL, NULL, NULL ) != M64ERR_SUCCESS) {
  throw std::runtime_error("failed to start core");
}

auto r = DebugMemWrite8(0x00, 127); // this segfaults!
std::cout << "result of write: " << (int) r << std::endl;

Stacktrace:

[0] from 0x00005555555a7370 in cp0_update_count+48 at mupen64plus-core/src/device/r4300/cp0.c:160
[1] from 0x00005555555a7459 in TLB_refill_exception+73 at mupen64plus-core/src/device/r4300/cp0.c:220
[2] from 0x00005555555a6fb0 in virtual_to_physical_address+176 at mupen64plus-core/src/device/r4300/tlb.c:143
[3] from 0x00005555555a8026 in r4300_write_aligned_word+70 at mupen64plus-core/src/device/r4300/r4300_core.c:360
[4] from 0x00005555555a2019 in write_memory_8+89 at mupen64plus-core/src/debugger/dbg_memory.c:364
[5] from 0x0000555555583d7c in DebugMemWrite8+44 at mupen64plus-core/src/api/debugger.c:347

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions