intel / hyperscan

High-performance regular expression matching library
https://www.hyperscan.io
Other
4.78k stars 710 forks source link

slice bounds out of range when test "examples/simplegrep" #195

Open onexpiece opened 4 years ago

onexpiece commented 4 years ago

On my mac run: time go run main.go ".*=.*" a, and got `.=. 258 Scanning 5 bytes with Hyperscan x=x x=x x=x

panic: runtime error: slice bounds out of range

goroutine 1 [running]: main.eventHandler(0x0, 0x0, 0x5, 0x0, 0x40e3700, 0xc00009a080, 0x4014102, 0x7ffeefbff3f0) /code/gohs/examples/simplegrep/main.go:75 +0x461 github.com/flier/gohs/hyperscan.hsMatchEventCallback(0xc000000000, 0x0, 0x5, 0xc000000000, 0xc0000b1dd0, 0x30) /code/gohs/hyperscan/internal.go:917 +0x61 github.com/flier/gohs/hyperscan._cgoexpwrap_2994d25f698d_hsMatchEventCallback(0xc000000000, 0x0, 0x5, 0x0, 0xc0000b1dd0, 0x0) _cgo_gotypes.go:946 +0x4f github.com/flier/gohs/hyperscan._Cfunc_hs_scan_cgo(0x4802400, 0xc0000c4000, 0x5, 0x4803800, 0xc0000b1dd0, 0xc000000000) _cgo_gotypes.go:626 +0x4d github.com/flier/gohs/hyperscan.hsScan.func1(0x4802400, 0xc0000c4000, 0x5, 0x205, 0x0, 0x4803800, 0xc0000b1dd0, 0xc0000c6100) /code/gohs/hyperscan/internal.go:932 +0xcd github.com/flier/gohs/hyperscan.hsScan(0x4802400, 0xc0000c4000, 0x5, 0x205, 0x0, 0x4803800, 0x4117be0, 0x40e3700, 0xc00009a080, 0xc0000c8001, ...) /code/gohs/hyperscan/internal.go:932 +0xbe github.com/flier/gohs/hyperscan.(*blockScanner).Scan(0xc00008a038, 0xc0000c4000, 0x5, 0x205, 0xc00008a058, 0x4117be0, 0x40e3700, 0xc00009a080, 0x0, 0x0) /code/gohs/hyperscan/runtime.go:298 +0xac main.main() /code/gohs/examples/simplegrep/main.go:148 +0x46b exit status 2

real 0m0.549s user 0m0.448s sys 0m0.402s`

Something wrong with the test case or the core code?

xiangwang1 commented 4 years ago

Hi @onexpiece,

We only support C/C++ and don't provide official go binding. It'll be good if you can run your test case with our native C code to see whether this issue is related to our own implementation or go binding.