Skip to content

Unaligned access triggers HardFault on Cortex-M4 #86

@pavmick

Description

@pavmick

Hi. Just recently I found this project. Looks awesome, thank you for your work.

I'm testing it in QEMU emulating a Cortex-M4 based microcontroller. I am getting a HardFault in function mvm_newNumber() at line 7153:

MVM_FLOAT64* pResult = GC_ALLOCATE_TYPE(vm, MVM_FLOAT64, TC_REF_FLOAT64);
*pResult = value;

Allocation returns a pointer that is not aligned on a 8-byte boundary. To store a double, the compiler generates a STRD instruction which requires such alignment. To work around this, I used memcpy:
memcpy(pResult, &value, sizeof *pResult);

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