[AD] [ alleg-Bugs-3143062 ] [PATCH] Fix al_get_standard_path on OS X

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Bugs item #3143062, was opened at 2010-12-23 09:58
Message generated for change (Tracker Item Submitted) made by jeffconnelly
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105665&aid=3143062&group_id=5665

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Mac OSX
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jeff Connelly aka shellreef (jeffconnelly)
Assigned to: Peter Hull (peterhull90)
Summary: [PATCH] Fix al_get_standard_path on OS X

Initial Comment:
On the Mac OS X port of Allegro, al_get_standard_path(ALLEGRO_EXENAME_PATH) is unreliable. It first tries to get the path from argv[0] if it is absolute, otherwise it tries to search $PATH for argv[0]. The launching program can specify anything for argv[0], so this method is unreliable, and it will crash if argv[0] is null (for example, if al_run_main() is called from a wrapper library without a valid argc/argv):

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
[Switching to process 41440]
0x000000000035f2fa in osx_get_path (id=<value temporarily unavailable, due to optimizations>) at /Users/jeff/Downloads/allegro-5.0.0rc3/src/macosx/system.m:662
662	            if (__crt0_argv[0][0] == '/') {

The comments ask if this code should use getprogname() instead, but the function you're looking for is _NSGetExecutablePath(). It simplifies the code considerably, removing the need to search $PATH, and works regardless of whatever was passed in argv[0]. 

Attached patched is against Allegro5.0.0rc3.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105665&aid=3143062&group_id=5665




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/