Arithmetic operations choose arch-dependant type and overflow in 32bit
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
- #946 @eyupcanakman による — マージされずにクローズ
評価
調査の方向性
まず、i386/golang コンテナ内で 32bit_test.go の再現テストを expr に対して実行し、val64 + 0 式がどのようにオペランドの型を選択するかを追跡します。32 ビットアーキテクチャで、他の整数演算を壊すことなく、テストが -2147483648 ではなく 2147483648 を報告すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Hi, thank you for your work and for reading. I found that arithmetic operations choose architecture-dependant types in some circumstances and can cause overflows in 32bit architectures.
Example
Given a value a of type int64 and a value b of any integer type, if we run the expression a+b then we will get int(a)+int(b), which can overflow in 32bit architectures.
Reproduction steps
First, save the following file as 32bit_test.go:
package main
import (
"fmt"
"math"
"testing"
"github.com/expr-lang/expr"
)
func TestOverflows32bit(t *testing.T) {
p, err := expr.Compile("val64 + 0")
if err != nil {
t.Fatalf("compile error: %v", err)
}
val, err := expr.Run(p, map[string]any{
"val64": int64(math.MaxInt32 + 1),
})
if err != nil {
t.Fatalf("run error: %v", err)
}
str := fmt.Sprint(val)
if str != "2147483648" {
t.Fatalf("expected %v, got %v", "2147483648", val)
}
}
Second, run it in a 32bit architecture docker container:
docker run --name go32 --rm -dit --platform linux/386 i386/golang:latest bash
docker exec go32 mkdir -p /go/src/test
docker cp 32bit_test.go go32:/go/src/test/main_test.go
docker exec -it go32 bash
> cd /go/src/test/
> go mod init
> go get github.com/expr-lang/expr
> go test
--- FAIL: TestOverflows32bit (0.01s)
main_test.go:24: expected 2147483648, got -2147483648
FAIL
exit status 1
FAIL test 0.043s
- 主要言語
- Go
- スター
- 8.1k
- フォーク
- 544
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 25
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
expr-lang/expr のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
expr-lang/expr#1037 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
count() without a predicate compiles for non-bool arrays and fails at run time対応中かも @minilan677-netizen が 2 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 57/100
メンテナーはふだん 1 日以内に返信
-
wontfix
難易度 4/5 1〜2日 初心者へのやさしさ 35/100
expr-lang/expr#995 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`find`, `findIndex`, `first` and `get` are type-checked as the element type where they return nil再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
expr-lang/expr#989 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
taskmanager: a failed v1alpha1 backup leaves the partial backup behind対応中かも @arshil42 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
labeler: read a limit above math.MaxInt as math.MaxInt in nonNegative (CodeQL alerts #20 and #21)オープンcost:approved factory:queued factory:tracking priority:p2 rank:12 ready-for-doing task:approved tokens:50k
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
sisaku-security/sisakulint#860 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openshift/sandboxed-containers-operator#4072 ·
メンテナーはふだん 1 日以内に返信
-
Correct local module testing instructions for Go sample contributors対応中かも @slievrly が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100