8000 Fixed crash due to uninitialized variable by kasedy · Pull Request #116 · rjwats/esp8266-react · GitHub
[go: up one dir, main page]

Skip to content

Fixed crash due to uninitialized variable #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 20, 2020
Merged

Conversation

kasedy
Copy link
Contributor
@kasedy kasedy commented May 20, 2020

Fixed crash.

@rjwats
Copy link
Owner
rjwats commented May 20, 2020

Looks like we might need to make this change in OTASettingsService too, _arduinoOTA is uninitialized there.

@kasedy
Copy link
Contributor Author
kasedy commented May 20, 2020

Right, it is the second place.

8000

@rjwats
Copy link
Owner
rjwats commented May 20, 2020

Out of interest, what steps induce the crash?

@kasedy
Copy link
Contributor Author
kasedy commented May 20, 2020

Nothing special, just a piece of bad luck.

It starts crashing on boot as I reformat the code. I create ESP8266React dynamically with new operator and have so called "Emergency Protocol" that works prior instancing ESP8266React.

Usually when program starts all memory (heap+stack) filled with zeros. So you don't see the problem with an example code as it declares global instance of ESP8266React. It is the first object that program creates in a fresh memory.

In my case ESP8266React reuses memory previously occupied by "Emergency Protocol". C++ delete operator marks a piece of memory as free but doesn't wipe it out. A a result uninitialized pointer get a random value.

@rjwats rjwats merged commit 4e6823c into rjwats:master May 20, 2020
@rjwats
Copy link
Owner
rjwats commented May 20, 2020 via email
723D

@kasedy kasedy deleted the fix-crash branch May 21, 2020 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0