-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix core dump due to memory corruption #24
Conversation
Amazing catch @a8jan |
src/Joy4004482.cpp
Outdated
@@ -19,18 +19,16 @@ | |||
#include <stdexcept> | |||
#include "Joy4004482.h" | |||
//--------------------------------------------------------------------------- | |||
Joy4004482::Joy4004482(IifGPIO *pio, TSettings::SetJoystick* settings) | |||
Joy4004482::Joy4004482(IifGPIO *pio, TSettings::SetJoystick* settings) : | |||
joy{{ nullptr, nullptr, false, 0 }, { nullptr, nullptr, false, 0 }}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: What's difference between nullptr
and NULL
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I see, it's new C++11 keyword. But I think that we could put NULL
macro here a update globals.h to work with nullptr (I'll change it when I come back home).
src/Joy4004482.cpp
Outdated
this->pio = pio; | ||
this->settings = settings; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think, that we could set pio
and settings
same way?
So that throw (plus include) we could omit...? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I think we can reduce the constructor code to just initializer
Joy4004482::Joy4004482(IifGPIO *pio, TSettings::SetJoystick* settings) :
pio(pio),
settings(settings),
joy{{ NULL, NULL, false, 0 }, { NULL, NULL, false, 0 }},
joyCnt(0),
sameDev(false)
{
}
Confirmed that it works: #25 (comment) |
I was getting quite often core dumps when starting emulator, e.g:
finding the cause with help of valgrind:
To fix it, I changed the way the joy[2] was initialized in Joy4004482 constructor.
-jan