hyperscan icon indicating copy to clipboard operation
hyperscan copied to clipboard

Hyperscan throws an exception when compiling and scanning specific regex on 32-bit Windows

Open kiarashgl opened this issue 4 years ago • 0 comments

Hello, I have a problem with running Hyperscan on a program that is built for a 32-bit Windows system. (This problem is similar to #249.) When compiling some specific regular expressions, Hyperscan crashes and throws some a "read access violation exception " in the fdr.c file, the FDR_MAIN_LOOP(z, state,get_conf_stride_2); line. I think that there is a problem with Hyperscan.

Steps to reproduce (I am using Windows 10 - 64bit and building a 32-bit application):

  1. Build and install Hyperscan using vcpkg. (Version 5.2.1 is installed right now.)
  2. Compile and run the following code with Clang compiler in x86-Release mode, using Visual Studio.
#include <hs/hs.h>
#include <iostream>
const match_event_handler handler =
[](unsigned int id, unsigned long long /*from*/, unsigned long long /*to*/, unsigned int /*flags*/, void* /*context*/)
-> int
{
    std::cout << "Matched " << id << std::endl;

    return 0;
};

int main()
{
    hs_database_t* db = nullptr;
    hs_scratch_t* scratch = nullptr;
    hs_compile_error_t* error;
    char s[4] = "abc";
    if (hs_compile("a[[:alpha:]]c", HS_FLAG_DOTALL | HS_FLAG_ALLOWEMPTY | HS_FLAG_MULTILINE | HS_FLAG_UTF8, 
    HS_MODE_BLOCK, nullptr, &db, &error) != HS_SUCCESS)
        std::cout << "Error in compilation" << std::endl;

    if (hs_alloc_scratch(db, &scratch) != HS_SUCCESS)
        std::cout << "Error in allocating scratch" << std::endl;

    hs_scan(db, s, 3, 0, scratch, handler, nullptr);

    return 0;
}

This code correctly runs in the x64 mode, but an exception is thrown in the x86 mode.

kiarashgl avatar Sep 23 '20 16:09 kiarashgl