-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
I suspect that there is a use-after-free issue in this library.
To debug the issue, I tried to run the tests with -msan
CC=clang CXX=clang++ CGO_ENABLED=1 go test -msan -count 1 -tags=re2_cgo -gcflags=all=-d=checkptr ./... -v
=== RUN TestGoodCompile
--- PASS: TestGoodCompile (0.00s)
=== RUN TestBadCompile
--- PASS: TestBadCompile (8.00s)
=== RUN TestMatch
Uninitialized bytes in MemcmpInterceptorCommon at offset 0 inside [0x70e000007160, 7)
==665959==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x45b0de in __interceptor_memcmp (/tmp/go-build2368439342/b068/go-re2.test+0x45b0de) (BuildId: d4510294c2a600520685423ff62143a71d0c01bc)
#1 0x7f291050f1e6 in re2::RE2::Match(re2::StringPiece const&, unsigned long, unsigned long, re2::RE2::Anchor, re2::StringPiece*, int) const (/lib/x86_64-linux-gnu/libre2.so.9+0x461e6) (BuildId: 340a39bff0a1beba99aacf5743fa2d9881519d24)
#2 0x6677e3 (/tmp/go-build2368439342/b068/go-re2.test+0x6677e3) (BuildId: d4510294c2a600520685423ff62143a71d0c01bc)
#3 0x666a5c (/tmp/go-build2368439342/b068/go-re2.test+0x666a5c) (BuildId: d4510294c2a600520685423ff62143a71d0c01bc)
#4 0x51bf03 (/tmp/go-build2368439342/b068/go-re2.test+0x51bf03) (BuildId: d4510294c2a600520685423ff62143a71d0c01bc)
SUMMARY: MemorySanitizer: use-of-uninitialized-value (/tmp/go-build2368439342/b068/go-re2.test+0x45b0de) (BuildId: d4510294c2a600520685423ff62143a71d0c01bc) in __interceptor_memcmp
Exiting
FAIL github.com/wasilibs/go-re2 9.056s
=== RUN TestCompileLatin1
=== RUN TestCompileLatin1/\xac\xed\x00\x05/��\x00\x05t\x00\x04test
=== RUN TestCompileLatin1/\xac\xed\x00\x05/��\x00t\x00\x04test
=== RUN TestCompileLatin1/(?sm)\xac\xed\x00\x05/��\x00\x05t\x00\x04test
=== RUN TestCompileLatin1/(?sm)\xac\xed\x00\x05/��\x00t\x00\x04test
=== RUN TestCompileLatin1/ハロー/ハローワールド
=== RUN TestCompileLatin1/ハロー/グッバイワールド
--- PASS: TestCompileLatin1 (0.00s)
--- PASS: TestCompileLatin1/\xac\xed\x00\x05/��\x00\x05t\x00\x04test (0.00s)
--- PASS: TestCompileLatin1/\xac\xed\x00\x05/��\x00t\x00\x04test (0.00s)
--- PASS: TestCompileLatin1/(?sm)\xac\xed\x00\x05/��\x00\x05t\x00\x04test (0.00s)
--- PASS: TestCompileLatin1/(?sm)\xac\xed\x00\x05/��\x00t\x00\x04test (0.00s)
--- PASS: TestCompileLatin1/ハロー/ハローワールド (0.00s)
--- PASS: TestCompileLatin1/ハロー/グッバイワールド (0.00s)
PASS
ok github.com/wasilibs/go-re2/experimental 0.015s
? github.com/wasilibs/go-re2/internal [no test files]
? github.com/wasilibs/go-re2/internal/cre2 [no test files]
? github.com/wasilibs/go-re2/internal/alloc [no test files]
? github.com/wasilibs/go-re2/internal/memory [no test files]
FAIL
I'm not sure if the above issue (use-of-uninitialized-value) is actually an indication of a bug, but it would be nice to add -msan support to the testsuite.
Metadata
Metadata
Assignees
Labels
No labels