-
-
Notifications
You must be signed in to change notification settings - Fork 423
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
CS:GO Server Crash w/ fuzzy map names & self-compiled SM #910
Comments
What version of the VS toolchain are you compiling with? This could be an ABI compatibility issue. |
Does this still crash without PTaH? |
@psychonic commented on Oct 26, 2018, 4:16 PM EDT:
MSVC Version 1915 @KyleSanderson commented on Oct 26, 2018, 4:18 PM EDT:
It crashes without PTaH. |
Windows Server 2016 |
Does the same issue occur using the VS 2015 toolset? |
1 . 1 0 . 0 . 6 3 2 9 |
This is crashing in the CUtlVector's CUtlString's destructor, as the game is allocating memory for the strings then we're freeing it cross-CRT :( It's gross, but this works: diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp
index 9e2bad5b..d9b8b1c2 100644
--- a/core/HalfLife2.cpp
+++ b/core/HalfLife2.cpp
@@ -1245,9 +1245,10 @@ SMFindMapResult CHalfLife2::FindMap(const char *pMapName, char *pFoundMap, size_
static size_t helperCmdLen = strlen(pHelperCmd->GetName());
- CUtlVector<CUtlString> results;
- pHelperCmd->AutoCompleteSuggest(pMapName, results);
- if (results.Count() == 0)
+ // Intentionally leak this, it has allocation issues. (#910)
+ CUtlVector<CUtlString> *results = new CUtlVector<CUtlString>();
+ pHelperCmd->AutoCompleteSuggest(pMapName, *results);
+ if (results->Count() == 0)
return SMFindMapResult::NotFound;
// Results come back as you'd see in autocomplete. (ie. "changelevel fullmapnamehere"),
@@ -1255,14 +1256,14 @@ SMFindMapResult CHalfLife2::FindMap(const char *pMapName, char *pFoundMap, size_
// Like the engine, we're only going to deal with the first match.
- bool bExactMatch = Q_strcmp(pMapName, &results[0][helperCmdLen + 1]) == 0;
+ bool bExactMatch = Q_strcmp(pMapName, &(*results)[0][helperCmdLen + 1]) == 0;
if (bExactMatch)
{
return SMFindMapResult::Found;
}
else
{
- ke::SafeStrcpy(pFoundMap, nMapNameMax, &results[0][helperCmdLen + 1]);
+ ke::SafeStrcpy(pFoundMap, nMapNameMax, &(*results)[0][helperCmdLen + 1]);
return SMFindMapResult::FuzzyMatch;
}
If we wanted to avoid the leak, we'd need to locate a dtor for |
Or manually iterate, removing from vec and calling g_pMemAlloc->Free() on the strings. |
Is this still used on the next frame? Even if we stored the ptrs on nextlevel they wouldn't be used. Isn't the global memory allocator gone? This was one of the last things Alfred pulled iirc. |
It was removed on POSIX builds, on some engines, and then brought back to them on some (maybe all). This issue is Windows-specific though. |
`CHalfLife2::FindMap` works around the missing `IVEngineServer::FindMap` function by using the command autocompletion feature of the `changelevel` command. The function populates a `CUtlVector<CUtlString>` object with the auto completion results. The game allocates memory for the vector and strings and we try to free it. This crashes when the C Run-time library version differs. Fixes alliedmodders#910 like @psychonic suggested.
Help us help you
Environment
Description
When using a self-compiled version of SourceMod locally on Windows, every version since early October (first noticed, possibly earlier) has caused instant crashes when attempting to use fuzzy map names. Retail SourceMod versions do not have this issue. I'm compiling against up to date versions of hl2sdk and metamod, also building "retail" versions of SM under the master and 1.9-dev branches with no changes. There's likely some relevant information I'm missing here - I'll gladly fill in any necessary blanks!
@jason-e and @Headline have noticed the same issue and might have some more relevant information that I'm missing here. I believe this happens in both Windows and Linux builds.
Problematic Code (or Steps to Reproduce)
Compile latest SourceMod 1.9 or 1.10 locally for Windows, place on server, /nominate and instant crash.
Logs
https://crash.limetech.org/p3kreav6ojxu
The text was updated successfully, but these errors were encountered: