cre2
cre2 copied to clipboard
Memory corruption detected in cre2 library during regex cleanup
Description: A memory corruption issue has been detected in the cre2 library when cleaning up after regex operations. This issue was discovered using AddressSanitizer (ASan) and a fuzzing test.
Steps to Reproduce:
- Use the attached fuzzer code.
- Compile with AddressSanitizer enabled.
- Run the fuzzer until it triggers the error (typically within a few iterations).
Error Message: AddressSanitizer: CHECK failed: asan_allocator.cpp:190 "((old)) == ((kAllocBegMagic))" (0x0, 0xcc6e96b9cc6e96b9)
Call Stack: The error originates in the RE2 library's optimization process and propagates through the memory deallocation chain:
- re2::Prog::Optimize()
- re2::SparseSetT
::~SparseSetT() - re2::PODArray
::~PODArray() - operator delete(void*)
- __asan::QuarantineCallback::Recycle()
Root Cause: The issue appears to be a memory corruption or use-after-free bug in the RE2 library or the cre2 wrapper. The error is detected when trying to deallocate memory that has been corrupted or already freed during the regex cleanup process.
Attachments: https://drive.google.com/file/d/133m1_uQKpEESL4yEC19DJVMG5liwYsDb/view?usp=sharing
Additional Notes: The issue occurs with a fixed regex pattern "pattern_to_match", suggesting that the problem may be independent of the specific regex used. The error is triggered during the cleanup phase, indicating a potential issue with memory management or object lifetime.