Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Memory corruption in ofFilePath::getCurrentExePath() #1366

markpitchless opened this Issue · 2 comments

2 participants


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/
==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.


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


closed by #1831

@bilderbuchi bilderbuchi closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.