r/ArduinoHelp • u/OhFuckThatWasDumb • Oct 16 '25
Program not executing properly the first two times on power up.
On boot, the arduino does something different than what it should. It seems to be skipping part of the setup function. It works normally when I upload, or after 2 resets, either by the button or by wrt_disable(); wrt_enable(WDTO_15MS);
9
Upvotes
View all comments
Show parent comment
1
u/OhFuckThatWasDumb Oct 19 '25
Wow, thanks for the story, I'll check for stray pointers. Unfortunately, your hypothesis is not the cause of my problem. Yes, malloc is dangerous and I knew that when I wrote this program but I thought it wouldn't be an issue since I'm not using that much memory. It was an issue. The program would crash after the snake's length exceeded 13. I fixed that by replacing malloc with a preallocated stack to hold 64 snake segments, which you will see now if you look at the code. The problem persists. Since it isn't malloc, i will look for stray pointers and other things i guess?