Stack overflow when broadcasting results in StaticInt eltype

オープン
#1 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
julia
領域
performance

調査の方向性

まず Julia で両方の例を再現し、次に src/static.jl:108 と、Base._range および 107-118 行付近の Julia の base/range.jl を調べます。StaticInt の範囲がどのように構築され、slicing がどのように StepRange に到達するかを追跡します。完了の条件は、broadcasting でオーバーフローが発生しなくなり、示されているステップ付き範囲の式が報告された MethodError を発生させなくなることです。

索引モデルが issue の本文から書いたものです。

説明

Found this...

julia> import ArrayInterface: StaticInt

julia> r = StaticInt(1):4
StaticInt{1}():StaticInt{1}():4

julia> broadcast(-, r, StaticInt(1))
ERROR: StackOverflowError:
Stacktrace:
 [1] UnitRange{StaticInt{0}}(::StaticInt{0}, ::StaticInt{3}) at /Users/zchristensen/.julia/packages/ArrayInterface/NbkVT/src/static.jl:108 (repeats 79984 times)

...and traced the issue back to Base._range assuming that UnitRange should be formed with an element type that is a StaticInt.

The easiest way to fix this would be our own Base._range(::StaticInt, ...), but I'm not sure if that's a good entry point since it's not public API.

Edit:
also found this

julia> (StaticInt(1):10)[1:2:6]
ERROR: MethodError: no method matching StepRange{StaticInt{1},Int64}(::StaticInt{1}, ::Int64, ::StaticInt{5})
Closest candidates are:
  StepRange{StaticInt{1},Int64}(::T, ::S, ::T) where {T, S} at range.jl:204
Stacktrace:
 [1] _rangestyle(::Base.Ordered, ::Base.ArithmeticWraps, ::StaticInt{1}, ::Int64, ::Int64) at ./range.jl:118
 [2] _range at ./range.jl:116 [inlined]
 [3] #range#43 at ./range.jl:91 [inlined]
 [4] getindex(::ArrayInterface.OptionallyStaticUnitRange{StaticInt{1},Int64}, ::StepRange{Int64,Int64}) at ./range.jl:713
 [5] top-level scope at REPL[26]:1
主要言語
Julia
スター
14
フォーク
8
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

JuliaArrays/StaticArrayInterface.jl のほかの issue

JuliaArrays/StaticArrayInterface.jl の issue をすべて見る

似ている issue

Julia の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。