Skip to content

Spurious "Uninitialized_value"s of various origins #7

Description

@rokopt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions