Skip to content

Conversation

@helq
Copy link
Member

@helq helq commented Jan 12, 2024

This tiny fix should be merged into "master". It does not alter the behavior of CODES. It is a fix to a bug that appeared.

The bug in question is:

Improper use of variable declaration inside a scope provokes segfault on optimized code -O3

A variable was declared and defined under a scope that was disregarded. Later on, outside of the scope a reference to the variable was used again causing a segfault.

This expression was never executed (optimized out):

oc_params.nprocs = num_traces_of_job[lid.job];

because oc_params.nprocs was never used within the scope of oc_params.

Later on, a pointer to oc_params tries to access nprocs but this contains only garbage, and this triggers a segfault down the line.

A variable was declared and defined under a scope that was disregarded
later on when the variable was used again.

This expression was never executed:

> oc_params.nprocs = num_traces_of_job[lid.job];

because `oc_params.nprocs` was never executed. The line:

> params = (char*)&oc_params;

after was copying the `oc_params` variable into a new variable to be
used later. `oc_params` is not guaranteed to exist after the scope
closes, and this would provoke a segfault.
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

Successfully merging this pull request may close these issues.

2 participants