[physfs] Crash when used with SDL 2.0

Thomas Lokshall thomas.lokshall at gmail.com
Thu Nov 1 10:11:49 EDT 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/physfs/attachments/20121101/548a4983/attachment.htm>


More information about the physfs mailing list