Skip to content

Malloc problem #863

@FroggyCorp

Description

@FroggyCorp

Hi,

I have some no sense issue on malloc and i have no way to reproduce it with simple code. I have some program using malloc which work on nano/STM32 but not on a Attiny85 with 2 malloc during the setup().
The attiny reboot during the malloc BUT if i add some testing around malloc, the attiny don't reboot and the program work ? I checked some memory leak (at setup() ?) with oscillo with that kind of code :

`
int available = (RAMEND - (int)&__data_start + 1)
- ((int)&__data_end - (int)&__data_start)
- ((int)&__bss_end - (int)&__data_end)
- ((int) (__brkval == 0 ? (uint8_t *) &__heap_start : __brkval) - (int)&__bss_end)
- (RAMEND - (int)SP + 1);
pinMode(1, OUTPUT);

digitalWrite(1, LOW);

delay(100);
digitalWrite(1, HIGH);
delay(free_memory)
digitalWrite(1, LOW);
`
before and after the malloc, and i get enought memory (~300B) and the malloc take the correct amount of memory. The only fact to add that digitalWrite, make the program work. It could be delay issue, but i don't know.

So i changed all malloc by static allocation and no more problem.

Regards,

Metadata

Metadata

Assignees

No one assigned

    Labels

    CriticalSerious issue requiring priority fixhelp wantedmysteryMysterious issue not yet known to be bug, complication or other.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions