simavr icon indicating copy to clipboard operation
simavr copied to clipboard

AVR_MCU_VCD_SYMBOL only supports addresses in the IO space - and causes UB if used with other addresses

Open JarrettBillingsley opened this issue 5 years ago • 0 comments

I thought I'd use AVR_MCU_VCD_SYMBOL to trace the value of a variable in my program. It didn't do anything. So I dug into it more.

In sim_elf.c, avr_load_firmware calls avr_iomem_getirq with the address contained in the AVR_MCU_VCD_SYMBOL directive, but neither it nor avr_iomem_getirq check the address for validity.

So if you give the directive the address of a variable in your program, avr_iomem_getirq will silently access past the end of the avr->io array. Oops.

JarrettBillingsley avatar Mar 30 '19 06:03 JarrettBillingsley