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

[Feature Request] A method to catch entity lump parse failures #2198

Open
ghost opened this issue Jul 29, 2024 · 7 comments
Open

[Feature Request] A method to catch entity lump parse failures #2198

ghost opened this issue Jul 29, 2024 · 7 comments

Comments

@ghost
Copy link

ghost commented Jul 29, 2024

logicore.SetEntityLumpWritable(true);
g_pOnMapInit->PushString(pMapName);
g_pOnMapInit->Execute();
logicore.SetEntityLumpWritable(false);
if (!success)
{
logger->LogError("Map entity lump parsing for %s failed with error code %d on position %d", pMapName, parseError, position);
RETURN_META_VALUE(MRES_IGNORED, true);
}

Plugins like the SourcePawn plugin for Stripper will not be able to make changes if entity lump parsing fails. If there is a method to catch fails developers can find another work around such as reloading the map.

@asherkin
Copy link
Member

What parsing failures have you run into that would have been recoverable?

@ghost
Copy link
Author

ghost commented Jul 29, 2024

Without SM, some maps sometimes crash on map start with MapEntity_ParseAllEntities: found ? when expecting {.

With SM, instead of crash on map start receive log Map entity lump parsing for failed with error code 1 on position -1 and reloading map fixes it.

Entity lump does write the changes but does not appear in the map.

@nosoop
Copy link
Contributor

nosoop commented Jul 31, 2024

The entity lump is packed into the map file, so the general assumption is that a failure in parsing would only come from a malformed map file (which would not be a sometimes-issue that is fixed on a reload).

In your case, you could probably check that EntityLump.Length() == 0 during either OnMapInit() or OnMapStart(). Failures to parse mid-file would return a partly filled entity lump, but neither of those behaviors are strictly specified.

Error code 0 does suggest that parsing returned Status_OK, so I'm not sure how you're hitting this case. If you could list your environment and reproduction steps, that would probably help.

@ghost
Copy link
Author

ghost commented Aug 1, 2024

Sorry, meant error code 1. But I will try EntityLump.Length() == 0 as I guess what on position -1 does mean.

@nosoop
Copy link
Contributor

nosoop commented Aug 1, 2024

Position -1 would be end-of-file, so either the whole string was consumed (unlikely if you're hitting the parse failure) or the string was empty. Empty string would mean EntityLump.Length() == 0 should work in your case.

@ghost
Copy link
Author

ghost commented Aug 2, 2024

Unfortunately didn't work for my case. The map is tr_walkway. Stripper extension can make changes without issue. I am thinking maybe adding the success bool to OnMapInit.

@Alienmario
Copy link
Contributor

I have this error happen on only 1 map, at random (presumably after server has been running for some time).

  • I also have a plugin that does entity lump parsing by itself.
  • I don't remember this crash happening before SM added entitylump parsing, but it could also be a number of other things.
  • The root issue may come from the engine

Console

243872	170172.655221	L 10/18/2024 - 12:58:35: -------- Mapchange to coop_tropic_v2 --------
243873	170172.692781	L 10/18/2024 - 12:58:35: Map entity lump parsing for coop_tropic_v2 failed with error code 1 on position -1
243874	170172.712265	L 10/18/2024 - 12:58:35: [SM] Exception reported: Did not find closing " for keyvalue
243875	170172.712327	L 10/18/2024 - 12:58:35: [SM] Blaming: srccoop.smx
243876	170172.712371	L 10/18/2024 - 12:58:35: [SM] Call stack trace:
243877	170172.712389	L 10/18/2024 - 12:58:35: [SM]   [0] ThrowError
243878	170172.712408	L 10/18/2024 - 12:58:35: [SM]   [1] Line 495, srccoop\levellump::ParseMapEntities
243879	170172.712425	L 10/18/2024 - 12:58:35: [SM]   [2] Line 76, srccoop\manager::CoopManager.OnLevelInit
243880	170172.712442	L 10/18/2024 - 12:58:35: [SM]   [3] Line 304, c:\VCS\SourceCoop\scripting\srccoop.sp::Hook_OnLevelInit

Stack

0	sourcemod.2.hl2dm.so!ConCommandCleaner::UnlinkConCommandBase + 0x11
1	sourcemod.2.hl2dm.so!__SourceHook_FHCls_ICvarUnregisterConCommand0::CMyDelegateImpl::Call + 0x26
2	sourcemod.2.hl2dm.so!__SourceHook_FHCls_ICvarUnregisterConCommand0::Func + 0x90
3	metamod.2.hl2dm.so!SMConVarAccessor::Unregister [console.cpp:146 + 0x14] 
4	metamod.2.hl2dm.so!BaseProvider::UnregisterConCommandBase [provider_ep2.cpp:439 + 0x12] 
5	metamod.2.hl2dm.so!MetamodSource::UnregisterConCommandBase [metamod.cpp:1149 + 0x17] 
6	metamod.2.hl2dm.so!MetamodSource::UnregisterConCommandBase [metamod.cpp:1119 + 0xd] 
7	sourcemod.2.hl2dm.so!CoreProviderImpl::CommandImpl::~CommandImpl [logic_bridge.cpp:65060 + 0x51] 
8	sourcemod.2.hl2dm.so!CoreProviderImpl::~CoreProviderImpl [logic_bridge.cpp:65060 + 0x89] 
9	libc.so.6 + 0x3a333
10	libc.so.6!exit + 0x27
11	libtier0.so!_SpewMessage(SpewType_t, char const*, int, Color const*, char const*, char*) + 0x141
12	libtier0.so!Error + 0x2c
13	server_srv.so!MapEntity_ParseAllEntities(char const*, IMapEntityFilter*, bool) + 0x37c
14	server_srv.so!CServerGameDLL::LevelInit(char const*, char const*, char const*, char const*, bool, bool) + 0x2b4
15	metamod.2.hl2dm.so!__SourceHook_MFHCls_SGD_LevelInit::Func [metamod.cpp:83 + 0x31] 
16	engine_srv.so!CServerPlugin::LevelInit(char const*, char const*, char const*, char const*, bool, bool) + 0xd0
17	engine_srv.so!Host_Changelevel(bool, char const*, char const*) + 0x2b3
18	engine_srv.so!CHostState::State_ChangeLevelMP() + 0x45
19	engine_srv.so!CHostState::FrameUpdate(float) + 0xd1
20	engine_srv.so!HostState_Frame(float) + 0x19
21	engine_srv.so!CEngine::Frame() + 0x38e

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

No branches or pull requests

3 participants