Hi, I've been spending some time trying to track down the reason that parrot cannot run .pbc files on Win32. Basically...
C:\Perl\Parrot\parrot>parrot -o 99beer.pbc examples\assembly\99beer.pasm C:\Perl\Parrot\parrot>parrot 99beer.pbc Parrot VM: Can't open 99beer.pbc, code 0. error:imcc:main: Packfile loading failed Now, the file is certainly there. So what gives? I eventually traced the problem down to PIO_win32_open, where I found this:- fd = CreateFile(spath, fAcc, 0, NULL, fCreat, FILE_ATTRIBUTE_NORMAL, NULL); if (fd != INVALID_HANDLE_VALUE) { io = PIO_new(interpreter, type, flags, 0); io->fd = fd; return io; } else { int err = GetLastError(); if(err) {} } I added fprintf(stderr, "PIO_win32_open Error Code: %d\n", err); In the appropriate place and it showed me an error code of 32. According to: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/ system_error_codes.asp That error code means:- The process cannot access the file because it is being used by another process. If you change:- fd = CreateFile(spath, fAcc, 0, NULL, fCreat, FILE_ATTRIBUTE_NORMAL, NULL); To: fd = CreateFile(spath, fAcc, FILE_SHARE_READ, NULL, fCreat, FILE_ATTRIBUTE_NORMAL, NULL); Then it works. However, I suspect that isn't the solution, as the file must be being opened somewhere twice, or being opened and re-opened later, but not closed? Having said that, I'm pretty sure from the tests I've done that PIO_win32_open only gets called once, but could be wrong as I'm no expert on the guts of parrot and don't know if there are times when you can't fprintf or printf and see the output. FYI, I ran tests with and without my change (adding FILE_SHARE_READ) and it makes no difference to the number of failures. Or successes, for that matter. ;-) I've attached the change I did as a patch on the off-chance you want to apply it, although I'm still not convinced it's the real solution. :-) Take care, Jonathan
Index: io_win32.c =================================================================== RCS file: /cvs/public/parrot/io/io_win32.c,v retrieving revision 1.30 diff -w -r1.30 io_win32.c 159c159 < fd = CreateFile(spath, fAcc, 0, NULL, fCreat, FILE_ATTRIBUTE_NORMAL, NULL); --- > fd = CreateFile(spath, fAcc, FILE_SHARE_READ, NULL, fCreat, > FILE_ATTRIBUTE_NORMAL, NULL);