Skip to content

[WIP] [DeepTest] Division by zero in OnDataAcknowledged NetStats event path#5875

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/fix-6154722-217654199-bd55e2f8-8969-4af5-a48e-cedee1a33d2c
Draft

[WIP] [DeepTest] Division by zero in OnDataAcknowledged NetStats event path#5875
Copilot wants to merge 1 commit intomainfrom
copilot/fix-6154722-217654199-bd55e2f8-8969-4af5-a48e-cedee1a33d2c

Conversation

Copy link
Contributor

Copilot AI commented Mar 18, 2026

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original prompt

This section details on the original issue you should resolve

<issue_title>[DeepTest] Division by zero in OnDataAcknowledged NetStats event path</issue_title>
<issue_description>### Describe the bug
Location: src/core/cubic.c, line 701
Event.NETWORK_STATISTICS.Bandwidth = Cubic->CongestionWindow / Path->SmoothedRtt;

Root cause: Same division-by-zero pattern as #5833, but in the OnDataAcknowledged function's NetStatsEventEnabled path. If NetStatsEventEnabled is TRUE and an ACK is processed before SmoothedRtt is set, the same crash occurs.

Affected OS

  • Windows
  • Linux
  • macOS
  • Other (specify below)

Additional OS information

No response

MsQuic version

main

Steps taken to reproduce bug

  1. Add the following test in src/core/unittest/CubicTest.cpp
TEST(CubicTest, DeepTest_Bug_NetStatsEventDivByZero)
{
    QUIC_CONNECTION Connection;
    QUIC_SETTINGS_INTERNAL Settings{};
    Settings.InitialWindowPackets = 10;
    Settings.SendIdleTimeoutMs = 1000;

    InitializeMockConnection(Connection, 1280);
    Connection.Settings.NetStatsEventEnabled = TRUE;
    Connection.ClientCallbackHandler = DummyConnectionCallback;
    // SmoothedRtt is 0 by default

    CubicCongestionControlInitialize(&Connection.CongestionControl, &Settings);

    QUIC_CONGESTION_CONTROL_CUBIC* Cubic = &Connection.CongestionControl.Cubic;
    Cubic->BytesInFlight = 5000;

    QUIC_ACK_EVENT AckEvent;
    CxPlatZeroMemory(&AckEvent, sizeof(AckEvent));
    AckEvent.TimeNow = 1000000;
    AckEvent.LargestAck = 5;
    AckEvent.LargestSentPacketNumber = 10;
    AckEvent.NumRetransmittableBytes = 1000;
    AckEvent.NumTotalAckedRetransmittableBytes = 1000;
    AckEvent.SmoothedRtt = 0; // No RTT sample
    AckEvent.MinRtt = 0;
    AckEvent.MinRttValid = FALSE;
    AckEvent.AckedPackets = NULL;

    // This will crash with STATUS_INTEGER_DIVIDE_BY_ZERO
    // because Path->SmoothedRtt=0 and line 701 does: CongestionWindow / SmoothedRtt
    Connection.CongestionControl.QuicCongestionControlOnDataAcknowledged(
        &Connection.CongestionControl, &AckEvent);
}
  1. Build and run the test with filter CubicTest.DeepTest_Bug_NetStatsEventDivByZero

Expected behavior

Should not crash.

Actual outcome

STATUS_INTEGER_DIVIDE_BY_ZERO crash

Additional details

No response</issue_description>

<agent_instructions>Fix this bug and add the test case in appropriate file</agent_instructions>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

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.

[DeepTest] Division by zero in OnDataAcknowledged NetStats event path

2 participants