Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Segmentation fault #51

Open
FenzaFenz opened this issue Aug 27, 2017 · 9 comments
Open

Segmentation fault #51

FenzaFenz opened this issue Aug 27, 2017 · 9 comments

Comments

@FenzaFenz
Copy link

FenzaFenz commented Aug 27, 2017

*** Chocolate DukeNukem3D v1.0 ***

Scanning directory './' for a GRP file like 'duke3d*.grp'.
Loading duke3d.grp ...
GRP identified as: PLUTONIUM 1.4 
Commands: 
SDL display driver for the BUILD engine initializing.
  sdl_driver.c by Ryan C. Gordon ([email protected]).
Compiled Aug 27 2017 against SDL version 1.2.15 ...
Linked SDL version is 1.2.15 ...
Using SDL video driver "x11".Video Driver: 'x11'.
Using Setup file: 'duke3d.cfg'
CONFIG_ReadSetup...
duke3d.cfg does not exist. Don't forget to set it up!
STUB: CONTROL_ClearAssignments (CONTROL_ClearAssignments, control.c:471)
Compiling: 'GAME.CON'.
Including: 'DEFS.CON'.
Including: 'USER.CON'.
Code Size:64832 bytes(1794 labels).
Con version: Looks like v14
Initializing SDL joystick subsystem... (export environment variable BUILD_SDLJOYSTICK=none to skip)
SDL sees 1 joystick.
Stick #0: [ST LIS3LV02DL Accelerometer]
Using Stick #0.Joystick initialized. 3 axes, 0 buttons, 0 hats, 0 balls.
Segmentation fault (core dumped)
@fawtytoo
Copy link

I've just compiled the latest build and it SegFaults at:

clearbufbyte (D=D@entry=0x55810fe0, c=123, c@entry=125, a=a@entry=0) at fixedPoint_math.c:20
20 *(p++) = (uint8_t )((a & m[z])>>n[z]);

@darealshinji
Copy link
Contributor

So it fails here. If your build is 64 bit, does it also crash on a 32 bit version?

@fawtytoo
Copy link

The game works perfectly in 32bit. But not 64bit.

@fawtytoo
Copy link

fawtytoo commented Feb 21, 2018

I've done some tracking of the code and found this in Engine/src/unix_compat.h:28

// Horrible horrible macro: Watcom allowed memory pointer to be cast
// to a 32bits integer. The code is unfortunately stuffed with this :( !
#define FP_OFF(x) ((int32_t) (x))

Changing the type from an int32_t to a long helps the game continue but still SegFaults.
This time in the function clearview in Engine/src/engine.c:8995
Variable p clearly needs to be a long type, but it still SegFaults.

@fawtytoo
Copy link

Hmmm. Getting a bit further. If I put a return; at the beginning of the clearview function, the game then SegFaults at dorotatesprite in Engine/src/engine.c:3784

If I put a return; at the beginning of dorotatesprite, the game actually starts playing. Sort of.

@fawtytoo
Copy link

fawtytoo commented Feb 21, 2018

One more fix: In the function clearview, changing the type for variable p to uint8_t* fixes that function.
This leaves the dorotatesprite function. All I can work out is it's from line 3991 onwards in that function, but I can't see where.

EDIT: The remaining memory pointer problems all seem to be in Engine/src/draw.c (called from dorotatesprite) which is riddled with 32 bit pointers.

@fawtytoo
Copy link

Execution fails on Debian 9.3 64bit. It executes perfectly on Debian 9.3 32bit. Also fails on Ubuntu 17.10 64bit. But it does work on Linux Mint 18.2 64bit.

@rohit-n
Copy link
Contributor

rohit-n commented Mar 18, 2019

@phenest I just made a pull request of fixes for 64-bit. Please try my branch (https://github.com/rohit-n/chocolate_duke3D/tree/build-64bit) and let me know if you have any issues.

@fhomolka
Copy link

@phenest I just made a pull request of fixes for 64-bit. Please try my branch (https://github.com/rohit-n/chocolate_duke3D/tree/build-64bit) and let me know if you have any issues.

Sorry for necro-ing the issue, but will this be merged as a solution to this issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants