AUTO変数領域サイズ計算のワード桁あふれを修正 (GH#2 取りこぼし)#33
Merged
Conversation
Variable_clr_sub の v_initF パスで、変数領域サイズを a1 に加算する際 GH#2 修整時に str だけが ext.l + adda.l に直され、int/char/float は adda.w のまま残っていた。ワード加算は符号反転するため、1関数内に その型のローカル変数が int:約8192個 / float:約4096個 / char:約32765個 以上あると領域計算が破綻する。str と同じ32bit計算に揃えた。 実用閾値は高く即時被害は考えにくいが、GH#2 と同クラスの潜在バグ。 HAS.X でビルドし、グローバル(SELFTEST) と func ローカル int/char/float (autovar) の両方で正常動作を確認。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
src/*.hasの見逃しバグ確認ワークフロー中に発見。GH#2(str変数128個以上でワードオフセットが符号反転)の修整が AUTO(func ローカル)変数領域では str しか直っていなかった取りこぼしを修正する。詳細
XB2.HASのVariable_clr_sub(v_initF パス)は、型ごとに変数領域サイズをa1に加算してエリア先頭ポインタを並べる。GH#2 修整時に str だけext.l+adda.l(32bit)化され、int/char/float はadda.w(ワード)のまま残っていた。adda.wは加算値を符号拡張するため、サイズが $8000 以上になると符号反転して領域が壊れる。1関数内のその型のローカル変数数で:lsl.w #2→adda.w(×4)andi.w→adda.w(≈×1)lsl.w #3→adda.w(×8)ext.l+lsl.l #8+adda.lstr と同じ
ext.l+ 32bit 加算に揃え、閾値を約32767に引き上げた(実質無制限)。空の型(個数-1 = -1)はaddq.w #1を先に行う既存イディオムで 0 になり、ext.l後も正しく 0 のまま。clear パス(
a1_clr_d0x4)は a1 をポインタ後置増分で進め、ワード dbra の閾値も int/char/float とも ≥32768(str init 修整値と同等)なので変更不要。GLOBAL 変数領域(XBSTAT.HAS)は既に正しく long。影響
実用閾値(1関数に数千個のローカル変数)は高く即時被害は考えにくいが、GH#2 と同クラスの潜在バグであり、str の修整との一貫性も欠いていた。
検証
HAS.Xでビルドし run68 で:🤖 Generated with Claude Code