[AD] Mac OS X: file_exists bus error

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


In the latest revision of the 4.2 branch of Allegro code (5817 at time of writing) there is a problem with the file_exists function. Apparently, if the specific file you're looking for does not exist, nothing bad happens (it operates as intended). However, if it does exist, we get a bus error. I'm going to paste in the test program I wrote to ensure that it's broken in general (and not just in my project) as well as a backtrace after running it through GDB and making it produce the bus error as this information is probably useful.

Some notes about the code: currently it just looks for the directory "hello." I also tried nesting directories in the form of "hello/foo." If foo did not exist, the program worked fine. If foo did exist, but was not a directory, the program ran fine. If foo existed and was a directory, we get the bus error. The same symptoms happen when searching for normal files using the attribute of "~FA_DIREC" (anything but a directory)

Running PPC Mac OS X 10.4.6. I did a fresh update/depend/make/install/etc. If you need any more information, let me know

-Jay

CODE:
---
#include <allegro.h>

int main()
{
        allegro_init();
        if(file_exists("hello", FA_DIREC, NULL) == 0)
        {
                fprintf(stderr, "The directory doesn't exist!\n");
        }
        else
        {
                printf("Directory found!\n");
        }
        return 0;
}
END_OF_MAIN()
---

GDB Backtrace:
---
(gdb) file a.out
Reading symbols for shared libraries .... done
Reading symbols from /Users/jay/Desktop/test/a.out...done.
(gdb) run
Starting program: /Users/jay/Desktop/test/a.out
Reading symbols for shared libraries ................................................................................ done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000020
[Switching to process 3641 thread 0x3503]
0x900017dc in pthread_mutex_lock ()
(gdb) backtrace
#0  0x900017dc in pthread_mutex_lock ()
#1  0x9001b258 in closedir ()
#2  0x300cc0ac in al_findclose ()
#3  0x30027fb4 in file_exists ()
#4  0x00002a70 in _mangled_main ()
#5  0x00002f8c in call_user_main ()
#6  0x00002fcc in +[AllegroAppDelegate app_main:] ()
#7  0x92976194 in forkThreadForFunction ()
#8  0x9002ba68 in _pthread_body ()


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