Repository navigation
Utf8JsonReader: Do not allow non-standard line endings in single-line comments - #38036
Conversation
ahsonkhan
left a comment
There was a problem hiding this comment.
We need to throw if we see the custom separator characters in both Skip and Allow modes.
|
@ahsonkhan I've rewrote SkipComment logic for multi-segment almost completely and have unified Consume/Skip. Haven't did anything similar for single-segment yet. |
|
@krwq, reviewing this would take some time and there is a bit of a churn, can this wait till next week? Do you have a sense of perf impact here? |
|
Yes, this can wait. Since there is currently no perf tests related to comments I'll let you know when I write them 😄 |
|
Perf results are here: dotnet/performance#543 |
I ran the perf tests locally (between master and your branch) and was not able to reproduce your results: summary:
@adamsitnik - it looks like we are hitting a character limit on the ResultComparer output. Also, can the ResultComparer store the result to disk somewhere (by default - maybe md and csv) just like the actual perf runs (rather than us having to specify a path - maybe in one of the base/diff paths)? |
I am not sure what would be the best way to solve it. The default output is console, which has a limited width. Most probably the easiest thing to do right now would be to shorten the ID.
yes, you can pass the path to output csv file via |
I am aware of the |
|
@ahsonkhan ping, is there anything blocking here? I'm not personally concerned about tiny (< 20%) regression in perf here considering comments are not expected to be used in high perf scenarios and there have been couple of reliability fixes here |
| return SkipMultiLineCommentMultiSegment(localBuffer.Slice(1), leftOver); | ||
| } | ||
| ReadOnlySequence<byte> commentSequence = _sequence.Slice(start, end); | ||
| commentSequence = commentSequence.Slice(2, commentSequence.Length - 2 - tailBytesToIgnore); |
There was a problem hiding this comment.
Can we try to avoid the double slicing of the ReadOnlySequence?
Maybe we can already have the start SequencePosition be off-set by 2. and change end to account for the - 2 - tailBytesToIgnore
There was a problem hiding this comment.
I don't believe this is possible. SequencePosition doesn't know how to move by 2 since it may end up in different object which it doesn't know about (where ReadOnlySequence does)
Nope, nothing blocking.
Agreed. I am still a bit concerned about the regression (especially for the "skip" mode), but we can work on perf optimizations separately. Do you have the latest numbers based on your changes? We should double check if we have 10-20% regression on the "skip" case, because that is a bit too high. |
|
@krwq, any updates to this? |
|
@ahsonkhan, I have not had a chance to re-run this yet. Nothing has changes since you've run it yourself last time |
OK. Let me know when you have addressed the leftover feedback so we can merge this change in :) |
ahsonkhan
left a comment
There was a problem hiding this comment.
Please resolve the merge conflict. Otherwise, LGTM.
|
@ahsonkhan seems the conflict is that we repeated this fix: I'm building locally to double check my tests still build and run correctly after rebasing. |
… comments (dotnet/corefx#38036) * Fix handling comments * Apply feedback, unify Consume and Skip for multi-segment * address some missed comments * micro changes * replace tab with spaces * apply feedback Commit migrated from dotnet/corefx@fc8bd8e
Fixes: https://github.com/dotnet/corefx/issues/33321
Fixes: https://github.com/dotnet/corefx/issues/37931
(also some other fixes - see below)
Some Unicode characters (i.e. U+2028, U+2029) are considered line endings and are sometimes used in some attack vectors when coming over the wire.
This change causes that parser will throw an exception if such character is encountered in a comment.
Also fixes couple of issues w.r.t to single-line comment handling with both mult- and single segment case around EOF/final block which I haven't reported. I.e.:
\r{}//would cause parser to throw)Perf results are here: dotnet/performance#543