[physfs] Crash when used with SDL 2.0
Tai Chi Minh Ralph Eastwood
tcmreastwood at gmail.com
Thu Nov 1 10:17:57 EDT 2012
Did you compile SDL and PhysFS yourself? It could be that the libraries were built with different runtimes (that is, I'm aware of, one of the common linking-runtime crash issues with MSVC).
Ralph
On 1 Nov 2012, at 14:11, Thomas Lokshall <thomas.lokshall at gmail.com> wrote:
> I'm attempting to integrate PhysFS with SDL 2.0 (latest from mercurial) and there seems to be a conflict here.
>
> PhysFS 2.0.3 compiles and runs fine with the test program using Visual Studio 10.
>
> However, as soon as you introduce SDL to the equation, it causes crashes. It compiles fine with no errors.
>
> I made a skeleton program to test this:
>
> /* BEGIN */
>
> #include <stdio.h>
> #include <physfs.h>
>
> int main(int argc, char *argv[])
> {
> PHYSFS_init(argv[0]);
> getchar();
> PHYSFS_deinit();
> return 0;
> }
>
> /* END */
>
> This program works just fine. However, if you link with SDL and SDLmain and change the code to this:
>
> /* BEGIN */
>
> #include <stdio.h>
> #include <physfs.h>
> #include <SDL/SDL.h>
>
> int main(int argc, char *argv[])
> {
> SDL_Init(SDL_INIT_EVERYTHING);
> PHYSFS_init(argv[0]);
> getchar();
> PHYSFS_deinit();
> SDL_Quit();
> return 0;
> }
>
> /* END */
>
> This will cause the application to crash when it's calling PHYSFS_init.
>
> There are a lot of things that seem to go wrong in windows.c
> Most of it seems to be related to the API calls and memory allocation.
> It doesn't matter if SDL is initialized before or after. Just initializing it at all causes PhysFS to crash.
>
> The first line that fails during init is line 470 of windows.c:
> wstr = (LPWSTR) __PHYSFS_smallAlloc(psize * sizeof (WCHAR));
>
> I have a hunch that compiling this on other platforms might be more successful.
>
> Am I just doing something terribly wrong here or is PhysFS incompatible with SDL 2.0?
>
> Regards,
> Thomas Lokshall
> _______________________________________________
> physfs mailing list
> physfs at icculus.org
> http://icculus.org/mailman/listinfo/physfs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/physfs/attachments/20121101/b8e873fd/attachment.htm>
More information about the physfs
mailing list