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

Tiny fix that shows up only when running an experiment with the -O3 compilation flag #238

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

1 participant