Skip to content

Segmentation fault #6

@dwjbosman

Description

@dwjbosman

I am testing strtt on a STM32U5, it finds the RTT info but then crashes

./strtt -v 4 -ramstart 0x2023af49

I added some debugging code, but I don't know how to fix this:

    strtt.cpp:272
    
    // 2. Enumerate buffers start and size
    for (size_t i = 0; i < buffersCnt; i++)
    {
        // check only valid channels, eg. with size > 0 AND and something to read
        SEGGER_RTT_BUFFER bufferDesc = this->_rtt_info.pRttDescription->buffDesc[i];
        if ((bufferDesc.SizeOfBuffer) && (bufferDesc.RdOff != bufferDesc.WrOff))
        {
            start = bufferDesc.pBuffer - ramStart;
            size = bufferDesc.SizeOfBuffer;
            LOG_DEBUG("readrtt: pushblock pb=%u, rs=%u start = %u, size = %u",bufferDesc.pBuffer, ramStart,start, size);
            blocks.push_back(std::make_pair(start, size));
        }
    }

Debug: 96 62 strtt.cpp:281 readRtt(): readrtt: pushblock pb=539208521, rs=539209545 start = 4294966272, size = 1024

Somehow bufferDesc.pBuffer < ramStart, which causes start to overflow, which in turn causes _memory[start] to fail.

    LOG_DEBUG("readrtt: read2 %u bytes start=%u memsz=%lu", size,start, this->_memory.size());
    // ret = stlink_usb_layout_api.read_mem(this->_handle, start + RAM_START, -1, size, &this->_memory[start]);
    ret = stlink_usb_layout_api.read_mem(this->_handle, start + ramStart, -1, ((size / 4) * 4) + 4, &this->_memory[start]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions