Skip to content

Fix rare multi-packet string corruption #3505

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

Merged
merged 4 commits into from
Jul 24, 2025
Merged

Conversation

Wraith2
Copy link
Contributor

@Wraith2 Wraith2 commented Jul 23, 2025

Fixes #3504

The sample data provided in the original issue by @Suchiman showed me that there were multiple problems happening when reading long strings. The data in the new test would not successfully complete the first iteration without asserting and would throw an exception on the second iteration. The lengths of the values and their combinations over multiple packets are important, even the column name lengths contribute to the offsets so they have not been changed. The data itself is randomised from a production sample.

The changes add in asserts to ensure that if we are expecting to continue that we have a stored buffer to continue with. There was a case where no buffer was present at a continue point causing the tail end of a multi-packet string to be returned to the user successfully causing an incorrect data read.

The conditions in which buffers and lengths are stored in the snapshot are relaxed. This brings the code more into line with the more relaxed handling of replay to continue that was added in previous commits. Overall I'm happier with this lessening of complexity.

@Wraith2 Wraith2 requested a review from a team as a code owner July 23, 2025 00:56
@Wraith2 Wraith2 changed the title add test and simplify code to fix problems Fix rare multi-packet string corruption Jul 23, 2025
@Wraith2
Copy link
Contributor Author

Wraith2 commented Jul 23, 2025

@dotnet/sqlclientdevteam can I get a CI run please

@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link

codecov bot commented Jul 23, 2025

Codecov Report

Attention: Patch coverage is 36.36364% with 7 lines in your changes missing coverage. Please review.

Project coverage is 58.95%. Comparing base (aaba34f) to head (ef06023).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
...nt/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs 0.00% 4 Missing ⚠️
.../netcore/src/Microsoft/Data/SqlClient/TdsParser.cs 0.00% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (aaba34f) and HEAD (ef06023). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (aaba34f) HEAD (ef06023)
addons 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3505      +/-   ##
==========================================
- Coverage   64.78%   58.95%   -5.83%     
==========================================
  Files         276      270       -6     
  Lines       62192    61865     -327     
==========================================
- Hits        40289    36472    -3817     
- Misses      21903    25393    +3490     
Flag Coverage Δ
addons ?
netcore 61.73% <57.14%> (-7.25%) ⬇️
netfx 62.54% <50.00%> (-3.89%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@mdaigle mdaigle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one small request

@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@paulmedynski paulmedynski added this to the 7.0-preview1 milestone Jul 24, 2025
@cheenamalhotra cheenamalhotra merged commit 63443f4 into dotnet:main Jul 24, 2025
237 checks passed
cheenamalhotra pushed a commit that referenced this pull request Jul 24, 2025
* add test and simplify code to fix problems

* review feedback

* review feedback

* review feedback
paulmedynski pushed a commit that referenced this pull request Jul 25, 2025
* add test and simplify code to fix problems

* review feedback

* review feedback

* review feedback

Co-authored-by: Wraith <wraith2@gmail.com>
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.

SqlClient gets stuck asynchronously reading string values in certain conditions
5 participants