Description

Code here is :

    tx := repo.db(ctx)
    if param.GroupID != 0 {
        tx = tx.Where(" group_id = ?", param.GroupID)
    }
    if param.AuthProductID != "" {
        tx = tx.Where(" product_pkid = ?", param.AuthProductID)
    }
    if param.CodeOrder != "" {
        tx = tx.Where(" code_order = ?", param.CodeOrder)
    }
    tx = tx.Select("group_id,auth_product,product_pkid,count(case when status=2 then status end) as used_num,count(case when status=3 then status end) as expire_num,count(case when status=1 then status end) as idle_num").Group("group_id,auth_product,product_pkid")
    if err = tx.Count(&total).Error; err != nil {
        return
    }
    err = tx.Offset(param.Offset).Limit(param.Limit).Order("group_id DESC").Find(&rows).Error

We got panic below:

fatal error: fault [signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x7e2fda] goroutine 1239 [running]: runtime.throw({0x13afc32?, 0x60?}) /usr/local/go/src/runtime/panic.go:1077 +0x5c fp=0xc0005aee28 sp=0xc0005aedf8 pc=0x43eadc runtime.sigpanic() /usr/local/go/src/runtime/signal_unix.go:875 +0x285 fp=0xc0005aee88 sp=0xc0005aee28 pc=0x455ae5 regexp.(*Regexp).doOnePass(0xc0000d4a01, {0x0?, 0x0}, {0x0, 0x0, 0x0}, {0xc00061ce80, 0x1c}, 0x0, 0x0, ...) /usr/local/go/src/regexp/exec.go:429 +0x31a fp=0xc0005aef40 sp=0xc0005aee88 pc=0x7e2fda regexp.(*Regexp).doExecute(0x48be4b?, {0x0?, 0x0?}, {0x0?, 0x468b9e?, 0x409e00?}, {0xc00061ce80?, 0xc00006dc40?}, 0x18?, 0x0, ...) /usr/local/go/src/regexp/exec.go:532 +0x2a8 fp=0xc0005aeff0 sp=0xc0005aef40 pc=0x7e3848 regexp.(*Regexp).doMatch(...) /usr/local/go/src/regexp/exec.go:514 regexp.(*Regexp).MatchString(...) /usr/local/go/src/regexp/regexp.go:533 github.com/jinzhu/inflection.Plural({0xc00061ce80, 0x1c}) /home/user/go/pkg/mod/github.com/jinzhu/inflection@v1.0.0/inflections.go:258 +0xca fp=0xc0005af098 sp=0xc0005aeff0 pc=0x8a338a gorm.io/gorm/schema.NamingStrategy.TableName({{0x0, 0x0}, 0x0, {0x0, 0x0}, 0x0}, {0x115810b?, 0x499e65?}) /home/user/go/pkg/mod/gorm.io/gorm@v1.24.0/schema/naming.go:42 +0x92 fp=0xc0005af0e8 sp=0xc0005af098 pc=0x8cfe72 gorm.io/gorm/schema.(*NamingStrategy).TableName(0x15b0688?, {0x115810b?, 0x1320e80?}) <autogenerated>:1 +0x73 fp=0xc0005af168 sp=0xc0005af0e8 pc=0x8dee53 gorm.io/gorm/schema.ParseWithSpecialTableName({0x1191220, 0xc0003c97d0}, 0xc000119ba0, {0x15a2aa0?, 0xc000513920?}, {0x0, 0x0}) /home/user/go/pkg/mod/gorm.io/gorm@v1.24.0/schema/schema.go:128 +0x642 fp=0xc0005af9b8 sp=0xc0005af168 pc=0x8d83a2 gorm.io/gorm/schema.Parse(...) /home/user/go/pkg/mod/gorm.io/gorm@v1.24.0/schema/schema.go:80 gorm.io/gorm.Scan({0x15a1078, 0xc0005a58c0}, 0xc00083c660, 0x0) /home/user/go/pkg/mod/gorm.io/gorm@v1.24.0/scan.go:188 +0x905 fp=0xc0005b00c8 sp=0xc0005af9b8 pc=0x8fb085 gorm.io/gorm/callbacks.Query(0xc00083c660) /home/user/go/pkg/mod/gorm.io/gorm@v1.24.0/callbacks/query.go:26 +0x105 fp=0xc0005b0140 sp=0xc0005b00c8 pc=0xb4c025 gorm.io/gorm.(*processor).Execute(0xc0005a84b0, 0xc0005139b0?) /home/user/go/pkg/mod/gorm.io/gorm@v1.24.0/callbacks.go:130 +0x399 fp=0xc0005b0218 sp=0xc0005b0140 pc=0x8e9419 gorm.io/gorm.(*DB).Find(0xc00083c660?, {0x1191220?, 0xc0003c97d0}, {0x0, 0x0, 0x0}) /home/user/go/pkg/mod/gorm.io/gorm@v1.24.0/finisher_api.go:170 +0x132 fp=0xc0005b0280 sp=0xc0005b0218 pc=0x8f0312

Comment From: baiyuxiong

This is an occasional bug.

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking