Skip to content

Commit

Permalink
19018: Fixes several rare crashes (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
howsohazard authored Jan 18, 2024
1 parent d229848 commit 467d51f
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 134 deletions.
7 changes: 2 additions & 5 deletions src/Amalgam/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,16 +976,13 @@ EvaluableNode *Parser::GetNodeFromRelativeCodePath(EvaluableNode *path)
case ENT_TARGET:
{
//first parameter is the number of steps to crawl up in the parent tree
size_t steps_up = 0;
size_t steps_up = 1;
if(path->GetOrderedChildNodes().size() > 0)
steps_up = static_cast<size_t>(EvaluableNode::ToNumber(path->GetOrderedChildNodes()[0]));

//at least need to go up one step
steps_up++;

//crawl up parse tree
EvaluableNode *result = path;
while(steps_up > 0 && result != nullptr)
for(size_t i = 0; i < steps_up && result != nullptr; i++)
{
auto found = parentNodes.find(result);
if(found != end(parentNodes))
Expand Down
7 changes: 5 additions & 2 deletions src/Amalgam/SeparableBoxFilterDataStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,11 @@ void SeparableBoxFilterDataStore::RemoveEntity(Entity *entity, size_t entity_ind
auto &val_to_overwrite = GetValue(entity_index, column_index);
auto type_to_overwrite = column_data->GetIndexValueType(entity_index);

auto &value_to_reassign = GetValue(entity_index_to_reassign, column_index);
auto value_type_to_reassign = columnData[column_index]->GetIndexValueType(entity_index_to_reassign);
auto &raw_value_to_reassign = GetValue(entity_index_to_reassign, column_index);
auto raw_value_type_to_reassign = column_data->GetIndexValueType(entity_index_to_reassign);
//need to resolve the value just in case things move around due to entity_index being deleted
auto value_to_reassign = column_data->GetResolvedValue(raw_value_type_to_reassign, raw_value_to_reassign);
auto value_type_to_reassign = column_data->GetResolvedValueType(raw_value_type_to_reassign);

//remove the value where it is
columnData[column_index]->DeleteIndexValue(value_type_to_reassign, value_to_reassign, entity_index_to_reassign);
Expand Down
6 changes: 3 additions & 3 deletions src/Amalgam/evaluablenode/EvaluableNodeTreeManipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2019,11 +2019,11 @@ CompactHashMap<EvaluableNodeType, double> EvaluableNodeTreeManipulation::evaluab
{ENT_NULL, 0.75},

//data types
{ENT_LIST, 2.5},
{ENT_LIST, 2.0},
{ENT_ASSOC, 3.0},
{ENT_NUMBER, 8.0},
{ENT_STRING, 4.0},
{ENT_SYMBOL, 25.0},
{ENT_SYMBOL, 10.0},

//node types
{ENT_GET_TYPE, 0.25},
Expand Down Expand Up @@ -2137,7 +2137,7 @@ CompactHashMap<EvaluableNodeType, double> EvaluableNodeTreeManipulation::evaluab
{ENT_QUERY_NEAREST_GENERALIZED_DISTANCE, 0.2},

{ENT_COMPUTE_ENTITY_CONVICTIONS, 0.2},
{ENT_COMPUTE_ENTITY_GROUP_KL_DIVERGENCE, 0.2},
{ENT_COMPUTE_ENTITY_GROUP_KL_DIVERGENCE, 0.2},
{ENT_COMPUTE_ENTITY_DISTANCE_CONTRIBUTIONS, 0.2},
{ENT_COMPUTE_ENTITY_KL_DIVERGENCES, 0.2},

Expand Down
2 changes: 1 addition & 1 deletion src/Amalgam/interpreter/InterpreterOpcodesBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ EvaluableNodeReference Interpreter::InterpretNode_ENT_ARGS(EvaluableNode *en, bo
}

//make sure have a large enough stack
if(callStackNodes->size() >= depth + 1)
if(callStackNodes->size() > depth)
{
#ifdef MULTITHREAD_SUPPORT
Concurrency::ReadLock lock;
Expand Down
Loading

0 comments on commit 467d51f

Please sign in to comment.