Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22037

gcc - Local variable overwritting a static variable in .data

$
0
0

In a arm-gcc program (precisely a Atmel Studio 7 Project on a ATSAMC20E18A), I have a weird behavior where a local variable in a function (uint8_t tmp_buffer[ROWS][COLUMNS]) is placed at the beginning of the RAM (0x20000000), overwritting static variables in the .data section.

I would assume that all local variables be placed in the stack. I am running FreeRTOS 10 on the chip with heap_4.c, and there is plenty of heap available.

void _flash_write(struct _flash_device *const device, const uint32_t dst_addr, uint8_t *buffer, uint32_t length){    uint8_t  tmp_buffer[NVMCTRL_ROW_PAGES][NVMCTRL_PAGE_SIZE];    uint32_t row_start_addr, row_end_addr;    uint32_t i, j, k;    uint32_t wr_start_addr = dst_addr;...

the tmp_buffer gets filled up before the flash is written, which directly overwrittes the variables at the start of the RAM. There is no warning, no crash, not even a HardFault or SegFault.


Viewing all articles
Browse latest Browse all 22037

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>