OK I've learned a bit more about using gdb and have the traced whereabouts the error is.
This is part of the trace from gdb:
#0 0xb6def284 in fread () from /lib/arm-linux-gnueabihf/libc.so.6
#1 0x000475e0 in Sys_FileRead (handle=115, dst=<optimized out>, count=413116) at sys_sdl.c:218
#2 0x00010f5c in COM_LoadFile (path=0x51c6c "progs.dat", usehunk=<optimized out>) at common.c:1583
#3 0x0002e004 in PR_LoadProgs () at pr_edict.c:995
PR_LoadProgs() calls COM_LoadHunkFile() like this:
Code: Select all
progs = (dprograms_t *)COM_LoadHunkFile ("progs.dat");
This is the COM_LoadFile function:
Code: Select all
cache_user_t *loadcache;
byte *loadbuf;
int loadsize;
byte *COM_LoadFile (char *path, int usehunk)
{
int h;
byte *buf;
char base[32];
int len;
buf = NULL; // quiet compiler warning
// look for it in the filesystem or pack files
len = COM_OpenFile (path, &h);
if (h == -1)
return NULL;
// extract the filename base name for hunk tag
COM_FileBase (path, base);
if (usehunk == 1)
buf = Hunk_AllocName (len+1, base);
else if (usehunk == 2)
buf = Hunk_TempAlloc (len+1);
else if (usehunk == 0)
buf = Z_Malloc (len+1);
else if (usehunk == 3)
buf = Cache_Alloc (loadcache, len+1, base);
else if (usehunk == 4)
{
if (len+1 > loadsize)
buf = Hunk_TempAlloc (len+1);
else
buf = loadbuf;
}
else
Sys_Error ("COM_LoadFile: bad usehunk");
if (!buf)
Sys_Error ("COM_LoadFile: not enough space for %s", path);
((byte *)buf)[len] = 0;
Draw_BeginDisc ();
Sys_FileRead (h, buf, len);
COM_CloseFile (h);
Draw_EndDisc ();
return buf;
}
And finally the Sys_FileRead function where the call to fread is:
Code: Select all
int Sys_FileRead (int handle, void *dst, int count)
{
char *data;
int size, done;
size = 0;
if ( handle >= 0 ) {
data = dst;
while ( count > 0 ) {
done = fread (data, 1, count, sys_handles[handle]);
if ( done == 0 ) {
break;
}
data += done;
count -= done;
size += done;
}
}
return size;
}
Hopefully this will help

.