ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.65k stars 617 forks source link

Quicksave outputs terminal errors. #868

Open johndrinkwater opened 11 years ago

johndrinkwater commented 11 years ago

Whenever I press F6, about 20 lines of this appears:

FS:  Tried to Close NULL file handle!
FS:  Tried to Close NULL file handle!
FS:  Tried to Close NULL file handle!
FS:  Tried to Close NULL file handle!
FS:  Tried to Close NULL file handle!

Output from SAVE,

john@joran ~/Steam/SteamApps/common/Half-Life > ll bshift/SAVE/
-rw-rw-r-- 1 john 323752 2013-03-31 12:59 autosave01.sav
-rw-rw-r-- 1 john 327504 2013-03-31 12:59 autosave.sav
-rw-rw-r-- 1 john 147941 2013-03-31 14:11 ba_security2.HL1
-rw-rw-r-- 1 john    364 2013-03-31 14:11 ba_security2.HL2
-rw-rw-r-- 1 john      4 2013-03-31 14:11 ba_security2.HL3
-rw-rw-r-- 1 john 320494 2013-03-31 13:01 quick01.sav
-rw-rw-r-- 1 john 319148 2013-03-31 14:11 quick.sav

Full halflife output https://gist.github.com/johndrinkwater/5280552 Sysinfo https://gist.github.com/johndrinkwater/4721913

nmirthes commented 11 years ago

Confirmed. Seeing the same messages from both HL:BS and HL:OF.

FS: Tried to Close NULL file handle! FS: Tried to Close NULL file handle! FS: Tried to Close NULL file handle! Dropped Barney Calhoun from server Reason: Server shutting down

World module shutdown.

Server module shutdown.

FS: Tried to Close NULL file handle! FS: Tried to Close NULL file handle! FS: Tried to Close NULL file handle! Game removed: AppID 130 "Half-Life: Blue Shift (Beta)", ProcID 9369

FS: Tried to Close NULL file handle! FS: Tried to Close NULL file handle! FS: Tried to Close NULL file handle! Dropped Adrian Shephard from server Reason: Server shutting down

World module shutdown.

Server module shutdown.

scandir failed:/home/niko/.local/share/Steam/SteamApps/common/Half-Life/SAVE FS: Tried to Close NULL file handle! FS: Tried to Close NULL file handle! FS: Tried to Close NULL file handle! Game removed: AppID 50 "Half-Life: Opposing Force (Beta)", ProcID 9437

SamVanheer commented 5 years ago

I tested this on both Windows and Linux using the current public version, even with developer 2 it doesn't print anything from the filesystem. Even running the game from the command line doesn't print anything extra, other than the usual scandir failed message that you can see in the logs above.

johndrinkwater commented 5 years ago

Fresh install of Blue Shift, started into the game itself and hit F6 for quick save and saw the same message in the terminal that launched steam:

…
Game update: AppID 130 "", ProcID 5473, IP 0.0.0.0:27015
JS method call Messaging.PostMessage with 4 arguments
Loading decals from ba_maint

Loading decals from ba_security1

Unknown command: VModEnable

JS method call Messaging.PostMessage with 4 arguments

FS:  Tried to Close NULL file handle!
FS:  Tried to Close NULL file handle!
FS:  Tried to Close NULL file handle!
AppActive: not active
AppActive: active
Unknown command: -showscores
SamVanheer commented 5 years ago

I'm still unable to reproduce it, even if i use GDB to break if any warnings are logged by the filesystem.

Can you try running the game using GDB and a breakpoint set?

First install gdb if you don't have it: http://www.gdbtutorial.com/tutorial/how-install-gdb

Open a terminal and enter this:

cd path/to/Half-Life
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
gdb
file hl_linux
set args -game bshift
run

Once the game has loaded, open the terminal that has the GDB session and use CTRL+C to break. Enter this:

b CBaseFileSystem::Warning
continue

Now start a new game and save the game. It should break on the first warning that is logged.

Enter this:

bt

And then take the entire backtrace as shown and provide it. That should tell us which engine function is causing this to happen, which will narrow things down.

johndrinkwater commented 5 years ago
Breakpoint 1, CBaseFileSystem::Warning (this=0xf5895ca0 <__g_CFileSystem_Stdio_singleton>, level=4294967295, 
    fmt=0xf588f98c "FS:  Tried to Close NULL file handle!\n") at ../filesystem/FileSystem_Stdio/BaseFileSystem.cpp:1892
1892    ../filesystem/FileSystem_Stdio/BaseFileSystem.cpp: No such file or directory.
(gdb) bt
#0  CBaseFileSystem::Warning (this=0xf5895ca0 <__g_CFileSystem_Stdio_singleton>, level=4294967295, 
    fmt=0xf588f98c "FS:  Tried to Close NULL file handle!\n") at ../filesystem/FileSystem_Stdio/BaseFileSystem.cpp:1892
#1  0xf5885804 in CBaseFileSystem::Close (this=0xf5895ca0 <__g_CFileSystem_Stdio_singleton>, file=0x0)
    at ../filesystem/FileSystem_Stdio/BaseFileSystem.cpp:559
#2  0xf4618138 in FS_Close (file=0x0) at ../engine/filesystem_internal.cpp:75
#3  0xf4627335 in DirectoryCopy (pPath=0xffe97668 "SAVE/*.HL?", pFile=0x9439088) at ../engine/host_cmd.c:3181
#4  0xf4627970 in SaveGameSlot (pSaveName=0xecb65d80 "quick", 
    pSaveComment=0xffe97930 "#BA_SECURITYTITLE", ' ' <repeats 48 times>, "02:02") at ../engine/host_cmd.c:2148
#5  0xf4627dbd in Host_Savegame_f () at ../engine/host_cmd.c:2194
#6  Host_Savegame_f () at ../engine/host_cmd.c:2164
#7  0xf4608c0e in Cmd_ExecuteStringWithPrivilegeCheck (text=0xffe97a40 "save quick", bIsPrivileged=<optimised out>, 
    src=<optimised out>) at ../engine/cmd.c:1196
#8  0xf4608e4d in Cmd_ExecuteStringWithPrivilegeCheck (bIsPrivileged=true, src=src_command, text=0xffe97a40 "save quick")
    at ../engine/cmd.c:1155
#9  Cbuf_ExecuteFromBuffer (buf=0xf4e6faf0 <cmd_text>, bIsPrivileged=true) at ../engine/cmd.c:244
#10 0xf4608e72 in Cbuf_Execute () at ../engine/cmd.c:262
#11 0xf4620093 in _Host_Frame (time=0.0163528174) at ../engine/host.c:1384
#12 0xf4620542 in Host_Frame (time=0.0163528174, iState=1, stateInfo=0xffe97f6c) at ../engine/host.c:1522
#13 0xf464ce64 in CEngine::Frame (this=0xf4865a20 <g_Engine>) at ../engine/sys_engine.cpp:245
#14 0xf464a8f3 in RunListenServer (instance=0x0, basedir=0x804b220 <szBaseDir> "/mnt/media/Steam/steamapps/common/Half-Life", 
    cmdline=0x82626e8 "/mnt/media/Steam/steamapps/common/Half-Life/hl_linux -steam -game bshift", 
    postRestartCmdLineArgs=0x804d360 <main::szNewCommandParams> "", launcherFactory=
    0x8049350 <CreateInterfaceLocal(char const*, int*)>, filesystemFactory=0xf5889d40 <CreateInterface(char const*, int*)>)
    at ../engine/sys_dll2.cpp:946
#15 0x08048d67 in main (argc=4, argv=0xffe981a4) at ../launcher/launcher.cpp:439
(gdb) c
johndrinkwater commented 5 years ago

For a listing of my save files — pulled down from steam cloud when I installed the game yesterday.

john@joran /mnt/media/Steam/steamapps/common/Half-Life/bshift/save ❯ la
total 1.2M
-rwxrwxr-x 1 john 324k 2013-03-31 12:59 autosave01.sav*
-rwxrwxr-x 1 john 328k 2013-03-31 13:00 autosave.sav*
-rw-rw-r-- 1 john 149k 2019-05-07 14:23 ba_security2.HL1
-rw-rw-r-- 1 john  684 2019-05-07 14:23 ba_security2.HL2
-rw-rw-r-- 1 john    4 2019-05-07 14:23 ba_security2.HL3
-rwxrwxr-x 1 john 306k 2019-05-07 14:24 quick.sav*
SamVanheer commented 5 years ago

Looks like the engine tries to copy the contents of files with names matching SAVE/*.HL? into a single file, but the files are failing to open despite being found by a FindFirst/FindNext call.

File permissions look good so something inside the file open code must be failing somehow.

I see that there is debug code that can be activated by defining the environment variable DBG_PATHMATCH. This should output additional information, but will likely spam your terminal.

I suggest outputting it to a file and then searching for the debug output that is logged near the warning messages that are currently being logged.

Hopefully that'll tell us what's going wrong.

Edit: Also maybe try renaming the directory to use upper case SAVE as the name, since that's what the code is using.