[.NET 10 servicing] Backport #123295: Skip() past the end followed by Concat() still throws ArgumentOutOfRangeException on 10.0.12
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
release/10.0 の src/libraries/System.Linq/src/System/Linq/SkipTake.SpeedOpt.cs から始め、対象のメソッドを #123295 の main ブランチ版と比較します。添付された net10.0 の repro を実行して Concat().ToArray() の失敗を確認し、バックポートによって例外なしで 1 要素が生成されることを検証します。
索引モデルが issue の本文から書いたものです。
説明
Summary
Requesting a release/10.0 backport of #123295, which fixed #123284 on main on 2026-01-20. The bug is a regression in a GA LTS release (introduced by #112401 in .NET 10), the fix is a one-line bounds check, and it is still present in the current servicing release. #123284 is locked, so this is filed separately rather than as a comment there.
Still reproduces on .NET 10.0.12
Microsoft.NETCore.App 10.0.12, Windows x64, Release, net10.0 console app (two-file repro attached below):
.NET 10.0.12
array.Skip(2).ToArray() -> 0 element(s)
array.Take(2).Concat(array.Skip(2)).ToArray() -> THREW ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
at System.Linq.Enumerable.IListSkipTakeIterator`1.Fill(IList`1 source, Span`1 destination, Int32 sourceIndex)
at System.Linq.Enumerable.IListSkipTakeIterator`1.CopyTo(TSource[] array, Int32 arrayIndex)
at System.Linq.Enumerable.Concat2Iterator`1.ToArray()
list.Take(2).Concat(list.Skip(2)).ToArray() -> THREW ArgumentOutOfRangeException (same stack)
Bare Skip(n).ToArray() past the end is fine; the throw is in the CopyTo/Fill path that Concat (and anything else that fills from the iterator) uses.
Branch state
main:src/libraries/System.Linq/src/System/Linq/SkipTake.SpeedOpt.csguards the copy withif (sourceIndex < sourceSpan.Length)(from #123295).release/10.0: the same method still readssourceSpan.Slice(sourceIndex, destination.Length).CopyTo(destination);unconditionally (line 151 as of 2026-09-27).- No
[release/10.0]PR references #123284 or #123295.
Impact
Hit in March 2026 in a production WinForms application after moving to .NET 10. A number-format helper did parts.Take(2).Select(...).Concat(parts.Skip(2)).ToArray() over the ;-separated sections of a .NET numeric format string; every single-section format ("N2", the common case) threw from ToArray() on a code path that had been stable since .NET Framework. "Take the first N, transform them, append the rest" is ordinary LINQ, and nothing in the exception points at Skip, so it is expensive to diagnose from the call site. The workaround (Skip(Math.Min(n, source.Length))) is not something most codebases will know to reach for, and the fix already exists.
Repro
using System.Runtime.InteropServices;
Console.WriteLine(RuntimeInformation.FrameworkDescription);
string[] one = ["N2"];
try
{
Console.WriteLine(one.Take(2).Concat(one.Skip(2)).ToArray().Length + " element(s)");
}
catch (Exception e)
{
Console.WriteLine($"{e.GetType().Name}: {e.Message}");
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>
Expected: 1 element(s). Actual on 10.0.12: ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Related
- Regression: #112401 (Improve Enumerable.Skip and Enumerable.Take performance)
- Report: #123284
- Fix on
main: #123295
- 主要言語
- C#
- スター
- 18.3k
- フォーク
- 5.6k
- 平均マージ
- 2日 22時間
- マージ済み PR(30日)
- 614
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/runtime のほかの issue
-
arch-wasm area-System.Threading.Tasks os-wasi
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/runtime#134955 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
area-System.Memory untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
dotnet/runtime#134840 · コメント 4 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-System.Threading blocking-clean-ci Known Build Error untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
dotnet/runtime#134679 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
ARM64: conditional compare rejects negative immediates the emitter can already encode as `ccmn`オープンarea-CodeGen-coreclr performance
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
dotnet/runtime#134663 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-System.Security untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
dotnet/runtime#134659 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
Money ExploitsオープンS: Untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
project-wayfarer/wayfarer-14#1628 ·
メンテナーはふだん 3 日以内に返信
-
:watch: Not Triaged dotnet-target-version
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
copilot documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 2 日以内に返信
-
untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
dotnet/dotnet-api-docs#13124 ·
メンテナーはふだん 1 日以内に返信
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信