Skip to content
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

Memory corruption in ofFilePath::getCurrentExePath() #1366

Closed
markpitchless opened this issue Jun 30, 2012 · 2 comments
Closed

Memory corruption in ofFilePath::getCurrentExePath() #1366

markpitchless opened this issue Jun 30, 2012 · 2 comments

Comments

@markpitchless
Copy link
Contributor

I'm seeing memory problems related to anything that is loading data. Symptons vary from segfaults on exit when using sound player to xmlSettings silently stopping working and failing to load or save. This is very dependent on the exact code, sometimes changing the order or adding an extra variable to the app results in different behavior. Digging around with valgrind I keep seeing this:

==15691== Conditional jump or move depends on uninitialised value(s)
==15691==    at 0x4C2972B: strlen (mc_replace_strmem.c:282)
==15691==    by 0x6C29B9F: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16)
==15691==    by 0x4A268D: ofFilePath::getCurrentExePath() (ofFileUtils.cpp:1304)
==15691==    by 0x4A26FA: ofFilePath::getCurrentExeDir() (ofFileUtils.cpp:1319)
==15691==    by 0x497E0D: dataPathRoot() (ofUtils.cpp:203)
==15691==    by 0x498056: ofToDataPath(std::string, bool) (ofUtils.cpp:259)
==15691==    by 0x414D37: ofxXmlSettings::loadFile(std::string const&) (ofxXmlSettings.cpp:73)
==15691==    by 0x4131F6: testApp::setup() (testApp.cpp:16)
==15691==    by 0x4DC666: ofNotifySetup() (ofEvents.cpp:77)
==15691==    by 0x484D53: ofAppGlutWindow::runAppViaInfiniteLoop(ofBaseApp*) (ofAppGlutWindow.cpp:331)
==15691==    by 0x485EF9: ofRunApp(ofBaseApp*) (ofAppRunner.cpp:78)
==15691==    by 0x4128E7: main (main.cpp:14)
==15691==  Uninitialised value was created by a stack allocation
==15691==    at 0x4A2629: ofFilePath::getCurrentExePath() (ofFileUtils.cpp:1300)

Which leads me to think getCurrentExePath is the culprit. It is definitely something to do with loading stuff from the data directory but I'm reaching the limit of my current c++ debugging skills.

The above can be reproduced by:

xmlSettingsExample $ make Debug
xmlSettingsExample $ cd bin
xmlSettingsExample $ valgrind --leak-check=yes --track-origins=yes --log-file=valgrind.out ./xmlSettingsExample_debug
xmlSettingsExample $ less valgrind.out

Running this against the develop branch SHA: 50cec4d
Ubunti Oneiric 64bit. Linux 3.0.0-22-generic #36-Ubuntu SMP Tue Jun 12 17:37:42 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux. gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1.
Nvidia driver 302.17

Let me know if you need more info. I'll try to find the time to construct an example that results in the load function stopping working or an actual segfault.

@bilderbuchi
Copy link
Member

thanks for the bug report. yes a reproducible example would be great!

@bilderbuchi
Copy link
Member

closed by #1831

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants