Segmentation Fault: 11 - running on macOS 10.14.2
charlesalec opened this issue · 3 comments
First and foremost, thank you :) an awesome idea, and something I'd really like to take some time to play with.
Everything compiles fine on macOS (10.14.2), however, when I run the client, I get a Segmentation Fault (11), and the server prints this:
`Using '/Users/charlesdowns/Desktop/qengine//assets' for writing.
couldn't exec default.cfg
couldn't exec config.cfg
couldn't exec autoexec.cfg
`
And then no other messages - does this mean it's initialised properly?
Thank you :)
On my system (Mac OS 10.13.6, although probably not specific to Mac OS) it segfaults when trying to output "Couldn't load pics/colormap.pcx" fatal error.
qengine/src/client/renderer/sw_main.c
Line 1244 in 619131d
Sys_Error
does not have additional argument before formating string:
qengine/src/platform/unix/system.c
Line 253 in 510c0e8
Maybe Com_Error
should be here? However, it's the same in original code:
https://github.com/id-Software/Quake-2/blob/372afde46e7defc9dd2d719a1732b8ace1fa096e/ref_soft/r_main.c#L1329
https://github.com/id-Software/Quake-2/blob/372afde46e7defc9dd2d719a1732b8ace1fa096e/linux/sys_linux.c#L86
Stack trace:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
* frame #0: 0x00007fff56c8d652 libsystem_c.dylib`__vfprintf + 15928
frame #1: 0x00007fff56cb2059 libsystem_c.dylib`__v2printf + 473
frame #2: 0x00007fff56c9734b libsystem_c.dylib`_vsnprintf + 415
frame #3: 0x00007fff56c973fe libsystem_c.dylib`vsnprintf + 80
frame #4: 0x0000000100006bb7 client`Sys_Error + 471
frame #5: 0x0000000100065fbb client`Draw_GetPalette + 75
frame #6: 0x0000000100065f36 client`RE_Init + 118
frame #7: 0x0000000100003bdd client`VID_LoadRefresh + 13
frame #8: 0x0000000100003bb8 client`VID_CheckChanges + 72
frame #9: 0x0000000100003ca3 client`VID_Init + 115
frame #10: 0x000000010001d633 client`CL_Init + 67
frame #11: 0x000000010004785d client`Qcommon_Init + 717
frame #12: 0x00000001000040e6 client`main + 294
frame #13: 0x00007fff56bf6015 libdyld.dylib`start + 1
Replacing it with Com_Error makes it exit correctly:
diff --git a/src/client/renderer/sw_main.c b/src/client/renderer/sw_main.c
index 91280e4..f5b1066 100644
--- a/src/client/renderer/sw_main.c
+++ b/src/client/renderer/sw_main.c
@@ -1241,7 +1241,7 @@ void Draw_GetPalette(void)
// get the palette and colormap
LoadPCX("pics/colormap.pcx", &vid_colormap, &pal, NULL, NULL);
if (!vid_colormap)
- Sys_Error(ERR_FATAL, "Couldn't load pics/colormap.pcx");
+ Com_Error(ERR_FATAL, "Couldn't load pics/colormap.pcx");
vid_alphamap = vid_colormap + 64 * 256;
out = (byte *) d_8to24table;
% ./client
qengine v0.1.0
==============
Byte ordering: little endian
Using '/Users/kolen/items/qengine/build/.//assets' for writing.
couldn't exec default.cfg
couldn't exec config.cfg
couldn't exec autoexec.cfg
Console initialized.
Sound init
Starting SDL audio callback.
SDL audio driver is "coreaudio".
SDL audio initialized.
Sound sampling rate: 44100
==== ShutdownGame ====
Closing SDL audio device...
SDL audio device shut down.
Cmd_RemoveCommand: force_centerview not added
Cmd_RemoveCommand: +mlook not added
Cmd_RemoveCommand: -mlook not added
Shutting down input.
recursive shutdown
Error: Couldn't load pics/colormap.pcx
Hello, thank you for your observation - indeed that does correct the issue. However, I still can't seem to get it to run correctly
With this commit, you'll be able to run the engine without the Q2 retail assets: 25c6b2e
These tools can be quite handy once you start creating the assets for your game: https://github.com/klaussilveira/qengine/tree/master/src/tools/assetgen