Comments (6)
very strange, only impact OSX, seems ok on Linux
from hyperscan.
Yes, we've also just reproduced it on OSX, but cannot on Linux.
We don't really know anything about Go or the integration, but our own unit tests pass on OSX, so we suspect it is something to do with the Go layer. Between 4.1 and 4.2 the only change in the API was adding a new error for HS_SCRATCH_IN_USE
.
from hyperscan.
@flier: Have you had any luck tracking down what was causing this? The pointer 0xb01dfacedebac1e
from the Go runtime apparently indicates a memory corruption issue on OS X -- perhaps a Hyperscan allocated pointer is getting freed by Go's GC when it shouldn't be?
from hyperscan.
I have upgrade to hyperscan v4.3.0 with golang 1.7, it still crash when I reuse/scan a reseted stream.
If I replace the hs_reset_stream with a pair of hs_close_stream/hs_open_stream, it could works.
Convey("Then reset the stream", func() {
//So(hsResetStream(stream, 0, s, h.Handle, nil), ShouldBeNil)
So(hsCloseStream(stream, s, h.Handle, nil), ShouldBeNil)
stream, err := hsOpenStream(db, 0)
So(stream, ShouldNotBeNil)
So(err, ShouldBeNil)
Convey("When scan the second part, should not be matched", func() {
So(hsScanStream(stream, []byte("stdef"), 0, s, h.Handle, nil), ShouldBeNil)
So(h.matched, ShouldBeNil)
})
})
When I use hs_reset_and_copy_stream in similar scene, it also could works very well.
Convey("Then copy the stream", func() {
stream2, err := hsCopyStream(stream)
So(stream2, ShouldNotBeNil)
So(err, ShouldBeNil)
Convey("When copied stream2 scan the second part, should be matched", func() {
So(hsScanStream(stream2, []byte("stdef"), 0, s, h.Handle, nil), ShouldBeNil)
So(h.matched, ShouldResemble, []matchEvent{{0, 0, 7, 0}})
Convey("When copied stream2 scan the second part again, should not be matched", func() {
h.matched = nil
So(hsScanStream(stream2, []byte("stdef"), 0, s, h.Handle, nil), ShouldBeNil)
So(h.matched, ShouldBeNil)
Convey("When copy and reset stream2", func() {
So(hsResetAndCopyStream(stream2, stream, s, h.Handle, nil), ShouldBeNil)
Convey("When copied and reset stream2 scan the second part again, should be matched", func() {
h.matched = nil
So(hsScanStream(stream2, []byte("stdef"), 0, s, h.Handle, nil), ShouldBeNil)
So(h.matched, ShouldResemble, []matchEvent{{0, 0, 7, 0}})
})
})
})
})
So(hsCloseStream(stream2, s, h.Handle, nil), ShouldBeNil)
})
It seems hs_reset_stream will write some pointer and corrupt memory, because when I call hs_reset_stream twice, it also crash
Convey("Then reset the stream", func() {
So(hsResetStream(stream, 0, s, h.Handle, nil), ShouldBeNil)
So(hsResetStream(stream, 0, s, h.Handle, nil), ShouldBeNil)
Convey("When scan the second part, should not be matched", func() {
So(hsScanStream(stream, []byte("stdef"), 0, s, h.Handle, nil), ShouldBeNil)
So(h.matched, ShouldBeNil)
})
})
func hsResetStream(stream hsStream, flags ScanFlag, scratch hsScratch, onEvent hsMatchEventHandler, context interface{}) error {
ctxt := &hsMatchEventContext{onEvent, context}
ret := C.hs_reset_stream_cgo(C.uintptr_t(uintptr(unsafe.Pointer(stream))), C.uint(flags),
C.uintptr_t(uintptr(unsafe.Pointer(scratch))), C.uintptr_t(uintptr(unsafe.Pointer(ctxt))))
if ret != C.HS_SUCCESS {
return HsError(ret)
}
return nil
}
static inline
hs_error_t hs_reset_stream_cgo(uintptr_t id, unsigned int flags, uintptr_t scratch, uintptr_t context) {
return hs_reset_stream((hs_stream_t *) id, flags, (hs_scratch_t *) scratch, hs_event_callback, (void *) context);
}
from hyperscan.
Thank you for reporting this - this turns out to be an issue with Clang builds (as found in Xcode) and the changes we had made in hs_reset_stream()
- it did not affect gcc
builds.
We have pushed v4.3.1 with a fix for this.
from hyperscan.
Verified, it could works now, thanks
from hyperscan.
Related Issues (20)
- What is the relationship between ssse3, sse4.1, sse4.2, avx, and avx2 in CPU instruction sets?
- Large Size of hs.lib File Compiled Under Windows and Optimization Options
- Regarding hs_multi_compile and hs_scan functionality HOT 1
- Approximate match (edit distance and hamming distance)
- unit-test failed with '-march=core2' HOT 1
- Question: Would hyperscan benefit from stacked SRAM cache ?
- The issue concerning the presence of "NOT" in logical combinations. HOT 1
- Tjv
- Windows binaries HOT 1
- 'From' parameter on match callback when 'HS_MODE_STREAM' mode always as zero HOT 1
- Numbered repeat doesn't work if the lower number is omitted HOT 1
- mutiple databases use one scratch ,if a delete a database,what can i do for scratch? HOT 1
- is hyperscan abandoned? HOT 4
- encountering problems of "multiple definition of XXX" when compiling hyperscan in centos with x86_64 HOT 1
- QUEDAS_FRIAEscaneo🐧
- Hyperscan panics if bounded repeat is exactly 32767
- memory leak occurs when calling hs_compile
- giving pattern with null to hs_compile_lit_multi HOT 1
- Chimera share Library
- Can parameters limitPatternLength and limitLiteralCount be increased? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hyperscan.