Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime error: makeslice: len out of range #193

Open
lw-leo opened this issue Sep 8, 2023 · 2 comments
Open

runtime error: makeslice: len out of range #193

lw-leo opened this issue Sep 8, 2023 · 2 comments

Comments

@lw-leo
Copy link

lw-leo commented Sep 8, 2023

数据量比较大时,查询数据时报错

panic({0xe79ae0, 0x114af40}) /go/src/runtime/panic.go:844 +0x258 github.com/taosdata/driver-go/v3/common/parser.rawConvertBinary(0xe71560?, 0xc000422270?, 0x7fb3220c8130?) /go/pkg/mod/github.com/taosdata/driver-go/[email protected]/common/parser/block.go:200 +0x59 github.com/taosdata/driver-go/v3/common/parser.ReadRow({0xc0003e0140, 0x13, 0xc0003e0140?}, 0x7fb2f005f4d5, 0x64, 0x0, {0xc001888c78, 0x13, 0xe75820?}, 0x0) /go/pkg/mod/github.com/taosdata/driver-go/[email protected]/common/parser/block.go:291 +0x14b github.com/taosdata/driver-go/v3/taosSql.(*rows).Next(0xc001424ae0, {0xc0003e0140, 0x13, 0x13}) /go/pkg/mod/github.com/taosdata/driver-go/[email protected]/taosSql/rows.go:79 +0x165

@sangshuduo
Copy link
Contributor

请提供复现代码

@fengtongxue
Copy link

golang client driver

version:

  • github.com/taosdata/driver-go/v3 v3.5.0

varchar 字段能存,但是 client driver 不能读,driver panic, int16 越界长度报错


  • 复现方式:
    td sql

     `sql CREATE STABLE `super_for_test` (`ts` TIMESTAMP, `json_value` VARCHAR(40000)) TAGS (`dev_id` VARCHAR(50));`
    
    INSERT INTO 'super_for_test_123' USING 'super_for_test'
    TAGS ('123')
    ('ts', 'json_value')
        VALUES (1704881588040,
    {{字符串len > int16}}
    );
    
  • golang clinet

func TestTDPanic(t *testing.T) {
    type Tmp struct {
        Ts      time.Time `json:"ts" db:"ts"` 
        JsonStr string    `json:"json_str" db:"json_value"`
    }
    rows, err := Ddata.td.Query("select ts, json_value from super_for_test")
    require.NoError(t, err)
    for rows.Next() {
        r := &Tmp{}
        var ts time.Time
        err = rows.Scan(&ts, &r.JsonStr)
        if err != nil {
            require.NoError(t, err)
        }
        fmt.Println(r)
    }

    //--- FAIL: TestTDPanic (0.07s)
    //panic: runtime error: makeslice: len out of range [recovered]
    // panic: runtime error: makeslice: len out of range
}
  • panic 位置

github.com/taosdata/driver-go/[email protected]/common/parser/block.go:200

func rawConvertBinary(pHeader, pStart uintptr, row int) driver.Value {
	offset := *((*int32)(unsafe.Pointer(pHeader + uintptr(row*4))))
	if offset == -1 {
		return nil
	}
	currentRow := unsafe.Pointer(pStart + uintptr(offset))
	clen := *((*int16)(currentRow))
	currentRow = unsafe.Pointer(uintptr(currentRow) + 2)
	println("**********: %v", clen)
	binaryVal := make([]byte, clen)

	for index := int16(0); index < clen; index++ {
		binaryVal[index] = *((*byte)(unsafe.Pointer(uintptr(currentRow) + uintptr(index))))
	}
	return string(binaryVal[:])
}

output:
**********: %v -32767

@sangshuduo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants