Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with invalid config #839

Closed
reinerh opened this issue Feb 18, 2024 · 1 comment
Closed

Crash with invalid config #839

reinerh opened this issue Feb 18, 2024 · 1 comment
Labels

Comments

@reinerh
Copy link
Contributor

reinerh commented Feb 18, 2024

When no config directory exists yet, and you run cdogs-sdl --help, a autosave.json file is generated with the following content.

$ rm -rf ~/.config/cdogs-sdl/
$ cdogs-sdl --help
C-Dogs SDL v2.0.0
SDL version 2.30.0
SDL_image version 2.8.2
SDL_mixer version 2.8.0
20240218-140856 INFO  [MAIN ] [files.c:670] SetupConfigDir(): Creating config dir /home/reiner/.config/cdogs-sdl/... 
20240218-140856 INFO  [MAIN ] [files.c:677] SetupConfigDir(): Config dir already exists.
Error loading config '/home/reiner/.config/cdogs-sdl/options.cnf'
20240218-140856 INFO  [MAIN ] [cdogs.c:141] main(): Command line (2 args): cdogs-sdl --help
Video Options:
    --fullscreen     Try and use a fullscreen video mode.
    --scale=n        Set pixel size to a factor of n
                       Factors: 1 - 16
    --screen=WxH     Set window size to W x H

Config:
    --config=K,V     Set arbitrary config option
                     Example: --config=Game.FriendlyFire=true
    --config         List all config options

Logging: logging is enabled per module and set at certain levels.
Log modules are: MAIN, NET, INPUT, ACTOR, SOUND, GFX, MAP, EDIT, PATH
Log levels are: TRACE, DEBUG, INFO, WARN, ERROR
    --log=M,L        Enable logging for module M at level L.

    --log=L          Enable logging for all modules at level L.

    --logfile=F      Log to file by filename

Other:
    --connect=host   (Experimental) connect to a game server
    --demo           (Experimental) run game for 30 seconds

20240218-140856 ERROR [NET  ] [net_client.c:78] NetClientTerminate(): Failed to shutdown listen socket: Socket operation on non-socket
{
	"Version": 3,
	"LastCampaignIndex": 0,
	"Missions": []
}

When cdogs-sdl is then started normally (without parameters), it crashes:

$ cdogs-sdl
C-Dogs SDL v2.0.0
SDL version 2.30.0
SDL_image version 2.8.2
SDL_mixer version 2.8.0
20240218-141050 INFO  [MAIN ] [files.c:670] SetupConfigDir(): Creating config dir /home/reiner/.config/cdogs-sdl/... 
20240218-141050 INFO  [MAIN ] [files.c:677] SetupConfigDir(): Config dir already exists.
Error loading config '/home/reiner/.config/cdogs-sdl/options.cnf'
20240218-141050 INFO  [MAIN ] [cdogs.c:141] main(): Command line (1 args): cdogs-sdl
20240218-141050 INFO  [GFX  ] [grafx.c:119] GraphicsInitialize(): graphics mode(320x240 2x)
20240218-141051 INFO  [MAIN ] [cdogs.c:192] main(): data dir(/usr/share/games/cdogs-sdl)
20240218-141051 INFO  [MAIN ] [cdogs.c:193] main(): config dir(/home/reiner/.config/cdogs-sdl/)
20240218-141052 INFO  [INPUT] [joystick.c:60] JoyInit(): 0 controllers found
20240218-141052 WARN  [MAIN ] [player_template.c:128] PlayerTemplatesLoad(): player templates file missing 'players.cnf'
20240218-141053 INFO  [MAIN ] [campaigns.c:200] LoadAllCampaigns(): Load campaigns from system...
20240218-141053 INFO  [MAIN ] [campaigns.c:204] LoadAllCampaigns(): Load campaigns from dir /usr/share/games/cdogs-sdl/missions...
20240218-141053 INFO  [MAIN ] [campaigns.c:209] LoadAllCampaigns(): Load dogfights from dir /usr/share/games/cdogs-sdl/dogfights...
20240218-141053 INFO  [MAIN ] [campaigns.c:213] LoadAllCampaigns(): Load quick play...
cdogs-sdl: ./src/cdogs/c_array.c:137: CArrayGet: Assertion `idx < a->size' failed.
Aborted (core dumped)
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
#1  0x00007ffad10b71cf in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2  0x00007ffad1069472 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffad10534b2 in __GI_abort () at ./stdlib/abort.c:79
#4  0x00007ffad10533d5 in __assert_fail_base
    (fmt=0x7ffad11c7dc8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x558ec45397e4 "idx < a->size", file=file@entry=0x558ec45397ce "./src/cdogs/c_array.c", line=line@entry=137, function=function@entry=0x558ec4545978 <__PRETTY_FUNCTION__.4> "CArrayGet") at ./assert/assert.c:92
#5  0x00007ffad10623a2 in __assert_fail
    (assertion=assertion@entry=0x558ec45397e4 "idx < a->size", file=file@entry=0x558ec45397ce "./src/cdogs/c_array.c", line=line@entry=137, function=function@entry=0x558ec4545978 <__PRETTY_FUNCTION__.4> "CArrayGet")
    at ./assert/assert.c:101
#6  0x0000558ec4470e65 in CArrayGet (idx=0, a=0x558ec4574ec8 <gAutosave+8>) at ./src/cdogs/c_array.c:137
#7  0x0000558ec44723e9 in CArrayGet (a=0x558ec4574ec8 <gAutosave+8>, idx=0) at ./src/cdogs/c_array.c:137
#8  0x0000558ec4433984 in AutosaveGetLastCampaign (a=<optimized out>) at ./src/autosave.c:445
#9  0x0000558ec444377d in MenuCreateStart (name=0x558ec4538b97 "Start", l=0x7ffcb81ce5a0, mainMenu=0x558ec91136d0) at ./src/mainmenu.c:304
#10 MenuCreateAll (handlers=<optimized out>, l=0x7ffcb81ce5a0, data=0x558ec91136d0) at ./src/mainmenu.c:276
#11 MainMenu (graphics=graphics@entry=0x558ec459aba0 <gGraphicsDevice>, l=l@entry=0x7ffcb81ce5a0) at ./src/mainmenu.c:88
#12 0x0000558ec442fb95 in main (argc=<optimized out>, argv=<optimized out>) at ./src/cdogs.c:252

It seems to be related to LastCampaignIndex. When I start cdogs-sdl initially normally, then it is set to -1 instead of 0. And after changing it manually to -1, cdogs-sdl can also start successfully.

@cxong cxong added the bug label Feb 19, 2024
@cxong cxong closed this as completed in 9ade064 Mar 24, 2024
@cxong
Copy link
Owner

cxong commented Mar 24, 2024

Nice find!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

2 participants