flanglet / kanzi

Fast lossless data compression in Java
Apache License 2.0
108 stars 18 forks source link

"index out of range" in Go BWT tranform #6

Closed pzo closed 7 years ago

pzo commented 7 years ago

Running kanzi/BWT transform on a block of "tra1" file from from calgary test suite generates an error message in the Go implementation (not in cpp). Thanks for all your work !

./app -compress -input=tra1-truncated -output=tra1-cpp -transform=bwt -entropy=none -overwrite Kanzi 1.0 (C) 2017, Frederic Langlet
Encoding ...
panic: runtime error: index out of range

goroutine 5 [running]: kanzi/transform.(DivSufSort).ssCompare3(0xc420070980, 0x2e69, 0x45ed, 0x2, 0x3) /home/user/go/src/kanzi/transform/DivSufSort.go:523 +0x13b kanzi/transform.(DivSufSort).ssMergeForward(0xc420070980, 0x3264, 0x1001, 0x1260, 0x2001, 0x2001, 0x2) /home/user/go/src/kanzi/transform/DivSufSort.go:863 +0x10f kanzi/transform.(DivSufSort).ssSwapMerge(0xc420070980, 0x3264, 0x1001, 0x1260, 0x2001, 0x2001, 0x6d5, 0x2) /home/user/go/src/kanzi/transform/DivSufSort.go:735 +0x5d2 kanzi/transform.(DivSufSort).ssSort(0xc420070980, 0x3264, 0x0, 0x26d6, 0x2fa7, 0x2bd, 0x2, 0x620b, 0x1) /home/user/go/src/kanzi/transform/DivSufSort.go:444 +0x1c7 kanzi/transform.(DivSufSort).sortTypeBstar(0xc420070980, 0xc42009d800, 0x100, 0x100, 0xc4201fa000, 0x10000, 0x10000, 0x620b, 0xc420070980)
/home/user/go/src/kanzi/transform/DivSufSort.go:280 +0x8c8
kanzi/transform.(
DivSufSort).ComputeSuffixArray(0xc420070980, 0xc4201e6000, 0x620b, 0x620b, 0x620d, 0x620d, 0xc420040b00) /home/user/go/src/kanzi/transform/DivSufSort.go:112 +0xdb kanzi/transform.(BWT).Forward(0xc42006a8a0, 0xc4201e6000, 0x620b, 0x620b, 0xc4201eca82, 0x620d, 0x620d, 0x3, 0xc420040c80, 0x40cd6d, ...) /home/user/go/src/kanzi/transform/BWT.go:137 +0x12e kanzi/function.(BWTBlockCodec).Forward(0xc42000c0b0, 0xc4201e6000, 0x620b, 0x620b, 0xc4201eca80, 0x620f, 0x620f, 0x4396bb, 0x10, 0x10000000053d420, ...) /home/user/go/src/kanzi/function/BWTBlockCodec.go:73 +0x110 kanzi/function.(ByteTransformSequence).Forward(0xc42000ade0, 0xc4201e6000, 0x620b, 0x620b, 0xc4201eca80, 0x620f, 0x620f, 0x0, 0x0, 0x0, ...) /home/user/go/src/kanzi/function/ByteTransformSequence.go:85 +0x1eb kanzi/io.(EncodingTask).encode(0xc4200cc380) /home/user/go/src/kanzi/io/CompressedStream.go:466 +0xb97 created by kanzi/io.(*CompressedOutputStream).processBlock /home/user/go/src/kanzi/io/CompressedStream.go:391 +0x39d

tra1-truncated.zip

flanglet commented 7 years ago

Thanks for the report. The issue was an incorrect variable update order in a loop in DivSufSort.go. It is working now.