ValveSoftware / ValveSoftware/source-sdk-2013
Access violation when calling either of the `Get/SetKeyValuesExpressionSymbol` funcs multiple times
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10k
- Forks
- 3k
- Avg merge
- 8d 11h
- Merged PRs (30d)
- 2
Description
The new expression evaluator functions that were backported from L4D2 and Swarm crash when trying to get or set a global conditional.
Here's some test code that sets the following conditionals and verifies them:
#include <vstdlib/IKeyValuesSystem.h>
KeyValuesSystem()->SetKeyValuesExpressionSymbol( "TEST1", true );
KeyValuesSystem()->SetKeyValuesExpressionSymbol( "TEST2", true ); // <-- Crashes here
KeyValuesSystem()->SetKeyValuesExpressionSymbol( "TEST3", false );
KeyValuesSystem()->SetKeyValuesExpressionSymbol( "TEST4", false );
Assert( KeyValuesSystem()->GetKeyValuesExpressionSymbol( "TEST1" ) );
Assert( KeyValuesSystem()->GetKeyValuesExpressionSymbol( "TEST2" ) );
Assert( !KeyValuesSystem()->GetKeyValuesExpressionSymbol( "TEST3" ) );
Assert( !KeyValuesSystem()->GetKeyValuesExpressionSymbol( "TEST4" ) );
And then uses the expression evaluator to determine if TEST1 is true and TEST3 is false:
#include <tier1/exprevaluator.h>
CExpressionEvaluator exprEval;
bool result;
exprEval.Evaluate( result, "$TEST1 && !$TEST3" ); // <-- Crashes when calling GetKeyValuesExpressionSymbol() inside this func
Assert( result );
Works fine in other branches. I'm also wondering why this was backported and not being used by KeyValues to replace the old EvaluateConditional function, like in other branches, or anywhere else in the SDK.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the crash with the provided SetKeyValuesExpressionSymbol and CExpressionEvaluator snippets. Start by tracing the declarations in vstdlib/IKeyValuesSystem.h and tier1/exprevaluator.h, then compare the existing KeyValues.cpp EvaluateConditional implementation with the linked other branch. Done means repeated get/set calls and the TEST1/TEST3 expression complete without an access violation and produce the asserted results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100