Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctness regression on x86 architecture #317

Closed
deenp03 opened this issue Nov 5, 2024 · 1 comment · Fixed by #318
Closed

Correctness regression on x86 architecture #317

deenp03 opened this issue Nov 5, 2024 · 1 comment · Fixed by #318
Assignees
Labels
bug Something isn't working
Milestone

Comments

@deenp03
Copy link

deenp03 commented Nov 5, 2024

Observed Errors:

  • x86 architecture: After commit 9af996b9367862e08314f5c8661166fba91774cc, matches are not being produced for certain pattern combinations (Failure can be reproduced when running the test below with a vectorscan version on or after this commit).
  • ARM architecture: functioning correctly and producing the expected results. We were unable to reproduce incorrect results on any commit that we tried.

How Failure was First Discovered:

Background

Internally, we use Vectorscan in our local ARM development environment as well as on x86 in production.

Issue Description

A specific test case was discovered to pass on local ARM machines but fail on x86 in production and our CI pipeline. This discrepancy highlighted a potential architecture-specific bug in Vectorscan.

Investigation Process

  1. Created a reproducible fixture and test case to isolate the issue.
  2. Utilized git bisect to pinpoint the exact commit that introduced the bug.
  3. Verified that the test passes successfully against the latest version of Hyperscan (5.4.2).

Findings

  • The bug appears to be isolated to Vectorscan and does not affect Hyperscan.
  • The issue was introduced in commit 9af996b9367862e08314f5c8661166fba91774cc originating from Fix all ASAN issues in vectorscan #93

Test File

#include <array>
#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>

#include "hs.h"

const char *patterns[] = {
    "^muvoy-nyemcynjywynamlahi/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^muvoy-nylyflahi/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^muvoy-wyljafo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^muvoy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^muvoazy-ailyjmflahio/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mffhvil-uvoaiyoo-mnwai/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mffhvil-ailysjalc/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mffhvil-oyfvjalc/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mffhvil-lcqyo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mfeoyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mny-nmlm-qjhnvflo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mny-ytlyjimeo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mny-jyz-sfq/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mnjyzayk-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-mqa-mimeclafo-khjdyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-mqa/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-mlljauvlahi-xy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-mlljauvlahi/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-mvlghjabmlahi/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-ua-nmlmljmioryj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-uaeeais/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-ujmin-wymovjywyil/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-ujmin-ovjzyco/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-uo-jyzayk-lhhe/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-fmwqmasi-mimeclafo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-fhjy-ehso/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-nmlm-yis/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-njvan/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-wmq-uannyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-wmjdylqemfy-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-ihlarafmlahio/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-qmfais-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-qmfais-lyolais/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-qyjrhjwmify/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-qatye/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-qhkyjlhheo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-qjynaflahi/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-jmidais/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-jyqhoalhjc/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-jyzofa-remllyiyn/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-ofjauy-yzyil-ux-ocif/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-lqw/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-ljyinonmog/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-lkyyl-fhwqhoyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-va-yzyilo-remllyiyn/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-voyjwhnyeais/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno-zanyh-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno_fhjy_remllyiyn/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mno_wmjdylqemfy_qjyolh/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mnono-yijafgyn-voyj-awq/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mnoqjazmfc-xy-mffyoo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mnoqjazmfc/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mnojll/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mnolkyyloyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mnljmfdyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mnljmfdyjolmsais/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mnzyjlaoyj-mqa/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^myw/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^myw_rhilo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mrraeamly-yirhjfyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^msmemlmi/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^msmlgm/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^msyil-lhheo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^manyi/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^majrehk-hdlm-voyjo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mdmogq/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^meumlho/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^meyjluhmjn/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mwea-sfq/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mwqearc-qjhn/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mwqearc-qjhsjmw-wmimsyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mwqearc/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mimeclafo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mila-oqmw/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mqmfgy-olmlaf-oalyo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mqq-qjhtc/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mvnayify-jykmjno/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mvnayifyo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mvnal-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mvjhjm/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mvlg-wylmnmlm/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^mvlhwmlyn-rymlvjy-qaehl/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^umnoymjfguhl/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^umlfg-mflahi/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^umbye-lhheo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uasxvyjc-fgmjsyumfd/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uasxvyjc-nmjloyfvjalc/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uasxvyjc-yjmoyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uasxvyjc-ehmnyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uasxvyjc-jysaoljmlahi/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uasxvyjc-vomsy-zaykyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uaslmueyjys/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uaeeais-qemlrhjw/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uaeeaisoyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uaeeaisoyjzafyolmsais/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uajnkmlfg-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^ualo-xy-mffyoo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uabaioasglo-rhjyfmol-j/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uabaioasglo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uabqjhraeyo-oyjzafymffl/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uehuolhjy-majrehk/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uehuolhjy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uhlwmdyj-reml-ehs/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uhlwmdyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uhvifyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^ux-lgjarl-aneo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^ux-zyjlafm-gymelg-qm/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^ujmin-omrylc-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^ujmin-ovjzyco-kyu/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^ujminyn-fw/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uvaenfmfgy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uvoaiyoo-fyilyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uvoaiyoo-aiuht/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^uvoaiyoo-oyllaiso/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lawyeaiywatyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lawyeaiyjmidyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lawyeaiyofhjyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lawyeaiyoyjzafy-mqa/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lawyeaiyoyjzafy-olmsais/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lawyeaiyoyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^laq_oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lhqujman/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lhqaf-ohfame-qjhhr/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lhqafot-jfq/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lhj-whi/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^ljmiowhsjarayj-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lonu/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^loo-sfq-fyjl-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lkyyl-yilalc-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lkyylnyfd/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lkyylcqay-olmsais/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lkaqqc-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lkalfgyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lkallyj-ihlyuhhd/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lkllj-majrehk-qds/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lcqymgymn-watyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lcqymgymn/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^lcjahi/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^vnew/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^vnq-nyz/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^vqehmn-wynam-oyjzyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^voyj-yilalc-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^voyj-awmsy-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^voyj-waeyolhiyo-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^voyj-oasime-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^voyj-lkyyl-sjmqg/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^zanyh-fhhjnaimlhj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^zanyh-watyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^zanyh-ihjwmeabmlahi-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^zanyh-ovwwmjc/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^zanyh-ljmiofhnyj-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^zanyhuajn/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^zaheyify-min-shjy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^zjq/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^zveinu/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^kminu/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^kyu-qmcwyilo-gllq/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^kyu-qmcwyilo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^kyumr-fa/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^tt-iork/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^bgyiswaiso/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fmimjc-mimecoao/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fmq-yis/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fmoohkmjc/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fne-nyz-uevyuajn/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fne-nyz-ay/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fne-nyz-we/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fne-nyz-jyzyivy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fyohvjfy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fgmjsyumfd/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fgvuucoiaqy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fa-airjm/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^faw-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^faoo-lhheuht/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fazaf-ailysjalc/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^feafdghvoy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^feayil-nmlm-yisaiyyjais/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^feayilyzyil-wynam-raelyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fehvn-nmlmljmioryj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fehvnogvlley/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fehvnoxejys/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fevolyj-jysaoljc/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fio-olmsais/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhwwyjfy-nmlm/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhwwvialayo-no/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhwwvialayo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhwqeamify/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhwqhoyj-uylm/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhwqvly/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhiras-nmlm-jysaoljmlahi/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhiras-yisaiy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhirasuvo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhilyil-xvmealc/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhiljhelhkyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhizyjoahi-yzyil-wmimsyj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhizyjoahimlljauvlahi/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhhjn-mvnalhj/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhhjn-wmailyimify/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    
    "^cop/devel/workflows-(prod|test)-.*/[0-9]+$", // Regex pattern that will match our fixture
    
    "^fhjy-mqa-lhheo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhjy-nmlm-eaujmjayo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhjywyljafo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhjlyt-majrehk/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhjlyt-wylm/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fhjlyt/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fjymlazyo-nmlmoylo/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fjymlhjo-nmlm/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fjynyilame-oyjzafy/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^foq-jyqhjlais/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fvmn/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fvjmlahi-va/nyzye/khjdrehko-(qjhn|lyol)-.*/0$",
    "^fvolhwyj-ytqyjayify-mqqo/nyzye/khjdrehko-.*/0$"
};

void generateIds(unsigned* arr, size_t size) {
    for (int i = 0; i < size; ++i) {
        arr[i] = i;
    }
}

bool g_matchFound = false;

static int eventHandler(unsigned int id, unsigned long long from,
                        unsigned long long to, unsigned int flags, void *ctx) {
    g_matchFound = true;
    std::cout << "Match found at offset " << from << std::endl;
    return 0;
}

int main() {
    hs_database_t *database;
    hs_compile_error_t *compile_err;
    

    const size_t patternSize = sizeof(patterns) / sizeof(patterns[0]);
    unsigned ids[patternSize] = {0};
    generateIds(ids, patternSize);

    const unsigned flag = HS_FLAG_SINGLEMATCH | HS_FLAG_ALLOWEMPTY | HS_FLAG_UTF8 | HS_FLAG_PREFILTER;
    std::vector<unsigned> flags;
    for (int i = 0; i < patternSize; ++i) {
        flags.push_back(flag);
    } 

    // Compile the pattern
    if (hs_compile_multi(patterns, flags.data(), ids, patternSize, HS_MODE_BLOCK, NULL, &database, &compile_err) != HS_SUCCESS) {
        std::cerr << "Failed to compile pattern: " << compile_err->message << std::endl;
        hs_free_compile_error(compile_err);
        return 1;
    }

    // Allocate scratch space
    hs_scratch_t *scratch = NULL;
    if (hs_alloc_scratch(database, &scratch) != HS_SUCCESS) {
        std::cerr << "Failed to allocate scratch space" << std::endl;
        hs_free_database(database);
        return 1;
    }

    // This input should match
    const char* input = "cop/devel/workflows-prod-build-cop-cop-ingestor/0";
    
    // Scan the input
    if (hs_scan(database, input, strlen(input), 0, scratch, eventHandler, NULL) != HS_SUCCESS) {
        std::cerr << "Error scanning input buffer" << std::endl;
        hs_free_scratch(scratch);
        hs_free_database(database);
        return 1;
    }

    // Clean up
    hs_free_scratch(scratch);
    hs_free_database(database);

    return g_matchFound ? 0: 1;
}
@markos markos self-assigned this Nov 6, 2024
@markos markos added the bug Something isn't working label Nov 6, 2024
@markos markos added this to the 5.4.12 milestone Nov 6, 2024
@markos
Copy link

markos commented Nov 6, 2024

Thank you for the bug report, we tested it on release and devel on both arches (x86 and arm) and verified the problem. We are going to fix this for the next version (5.4.12) whenever it becomes available.

markos pushed a commit that referenced this issue Nov 13, 2024
Revert the code that produced the regression error in #317 
Add the regression error to a unit test regressions.cpp along with the rebar tests

---------

Co-authored-by: gtsoul-tech <gtsoulkanakis@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants