cancel
Showing results for 
Search instead for 
Did you mean: 

LWIP_RAND uses newlib rand() and fails

Gustavo_AR
Associate II

CubeMX generated project defines

 

#define LWIP_RAND() ((u32_t)rand())

 

which fails with the following call stack...

Gustavo_AR_1-1726157473699.png

and the following assert text

assertion "REENT malloc succeeded" failed: file "/build/gnu-tools-for-stm32_12.3.rel1.20240612-1315/src/newlib/newlib/libc/stdlib/rand.c", line 82

Line 82 of rand.c is:

 

_REENT_CHECK_RAND48(reent);

 

which in turn ends up calling a malloc... 

I've read that reentrancy in newlib could cause problems, but I thought it would be memory corruption.

Is there a solution for this?

Thanks in advance!

0 REPLIES 0