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

Variable Machine::runUntilTime is used before initialization #1

Open
soyWXY opened this issue Sep 23, 2024 · 0 comments
Open

Variable Machine::runUntilTime is used before initialization #1

soyWXY opened this issue Sep 23, 2024 · 0 comments

Comments

@soyWXY
Copy link

soyWXY commented Sep 23, 2024

Description

In C++, a class member Machine::runUntilTime, whose type is int, won't be initialized automatically. The only place that sets runUntilTime is in Machine::Debugger(), but the snippet that invokes Debugger() checks the runUntilTime value first:

if (singleStep && (runUntilTime <= kernel->stats->totalTicks))
    Debugger();

This leads to a used-before-set undefined behavior.

Suggested Solution

Initialize Machine::runUntilTime in the constructor Machine::Machine().

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

1 participant