Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions encoding/codecv7_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
"encoding/hex"
"encoding/json"
"fmt"
"log"
"math/big"
"math/rand"
"net/http"
_ "net/http"
_ "net/http/pprof"
"strings"
Comment thread
yiweichi marked this conversation as resolved.
"testing"

Expand All @@ -17,6 +21,32 @@
"github.com/stretchr/testify/require"
)

// TestDecodeAllDeadlock tests the decompression of random bytes to trigger deadlock in zstd library.

func TestDecodeAllDeadlock(t *testing.T) {
t.Skip("Skip test that triggers deadlock in zstd library")

go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
}()

// generate some random bytes
randomBytes := make([]byte, maxBlobBytes)
rand.Read(randomBytes)

Check failure on line 35 in encoding/codecv7_test.go

View workflow job for this annotation

GitHub Actions / check

SA1019: rand.Read has been deprecated since Go 1.20 because it shouldn't be used: For almost all use cases, crypto/rand.Read is more appropriate. (staticcheck)

c := NewDACodecV8()

compressed, err := c.CompressScrollBatchBytes(randomBytes)
require.NoError(t, err)

// repeatedly decompress the bytes to trigger deadlock in zstd library
for i := 0; i < 100000; i++ {
uncompressed, err := decompressV7Bytes(compressed)
require.NoError(t, err)
require.Equal(t, randomBytes, uncompressed)
}
}

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
// TestCodecV7DABlockEncodeDecode tests the encoding and decoding of daBlockV7.
func TestCodecV7DABlockEncodeDecode(t *testing.T) {
codecV7, err := CodecFromVersion(CodecV7)
Expand Down
2 changes: 1 addition & 1 deletion encoding/codecv7_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ func decompressV7Bytes(compressedBytes []byte) ([]byte, error) {

compressedBytes = append(zstdMagicNumber, compressedBytes...)
r := bytes.NewReader(compressedBytes)
zr, err := zstd.NewReader(r)
zr, err := zstd.NewReader(r, zstd.WithDecoderConcurrency(1))
if err != nil {
return nil, fmt.Errorf("failed to create zstd reader: %w", err)
}
Expand Down
Loading