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

Spurious "Uninitialized_value"s of various origins #7

Open
rokopt opened this issue Oct 1, 2020 · 0 comments
Open

Spurious "Uninitialized_value"s of various origins #7

rokopt opened this issue Oct 1, 2020 · 0 comments

Comments

@rokopt
Copy link

rokopt commented Oct 1, 2020

Today I analyzed the following branch:

https://github.com/rokopt/stellar-core/tree/muse-dev-experiments

With the following results:

https://console.muse.dev/result/rokopt/stellar-core/01EKJR98Y8YSJBQDV5J6PGRHBN?tab=results

There are many "Uninitialized_value" errors, of which the ones I've examined so far all appear spurious to me. I expect some spurious errors to be inevitable, but I'll note these for your consideration even if they end up being no-action ones.

In some cases, it appears not to have realized that a variable was being declared and initialized at the same time:

Uninitialized_value
The value read from trimmed was never initialized.

 src/.../Scheduler.cpp 178:5

https://github.com/rokopt/stellar-core/blob/6692d6ab8f91d7bd8085b1786f04c7a606c134e1/src/util/Scheduler.cpp#L178:

void
Scheduler::trimSingleActionQueue(Qptr q, VirtualClock::time_point now)
{
    size_t trimmed = q->tryTrim(mLatencyWindow, now);
    mStats.mActionsDroppedDueToOverload += trimmed;
    mSize -= trimmed;
}

In some, it doesn't notice that a variable is initialized in both branches of an if:

Uninitialized_value
The value read from res was never initialized.

 src/.../SponsorshipUtils.cpp 814:5

https://github.com/rokopt/stellar-core/blob/6692d6ab8f91d7bd8085b1786f04c7a606c134e1/src/transactions/SponsorshipUtils.cpp#L814:

    if (sponsorship)
    {
        auto const& se = sponsorship.currentGeneralized().sponsorshipEntry();
        auto sponsoringAcc = loadAccount(ltx, se.sponsoringID);

        res = canCreateSignerWithSponsorship(
            header.current(), signerIt, sponsoringAcc.current(), acc.current());
        if (res == SponsorshipResult::SUCCESS)
        {
            createSignerWithSponsorship(signerIt, sponsoringAcc.current(),
                                        acc.current());
        }
    }
    else
    {
        res =
            canCreateSignerWithoutSponsorship(header.current(), acc.current());
        if (res == SponsorshipResult::SUCCESS)
        {
            createSignerWithoutSponsorship(acc.current());
        }
    }

    return res;

And similarly with a case:

Uninitialized_value
The value read from res was never initialized.

 src/.../BallotProtocol.cpp 1578:5

https://github.com/rokopt/stellar-core/blob/6692d6ab8f91d7bd8085b1786f04c7a606c134e1/src/scp/BallotProtocol.cpp#L1578:

{
    bool res;

    switch (st.pledges.type())
    {
    case SCP_ST_PREPARE:
    {
        auto const& p = st.pledges.prepare();
        res =
            (p.prepared && areBallotsLessAndCompatible(ballot, *p.prepared)) ||
            (p.preparedPrime &&
             areBallotsLessAndCompatible(ballot, *p.preparedPrime));
    }
    break;
    case SCP_ST_CONFIRM:
    {
        auto const& c = st.pledges.confirm();
        SCPBallot prepared(c.nPrepared, c.ballot.value);
        res = areBallotsLessAndCompatible(ballot, prepared);
    }
    break;
    case SCP_ST_EXTERNALIZE:
    {
        auto const& e = st.pledges.externalize();
        res = areBallotsCompatible(ballot, e.commit);
    }
    break;
    default:
        res = false;
        dbgAbort();
    }

    return res;
}
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