rrthomas / lrexlib

A Lua (5.1 and later) binding of various regex library APIs (POSIX, PCRE, PCRE2, GNU, Oniguruma and TRE)
Other
161 stars 29 forks source link

Crash on large string #19

Closed moteus closed 9 years ago

moteus commented 9 years ago

WinXP Lua 5.1 PCRE 8.36 lrexlib (master) I try implement basic utf8 validator and get AV on this code

local rex = require "rex_pcre"
local pat = rex.new("(?:"                             ..
  "(?:[\\0\1-\127])|"                                 ..
  "(?:[\194-\223][\123-\191])|"                       ..
         "(?:\224[\160-\191][\128-\191])|"            ..
  "(?:[\225-\236][\128-\191][\128-\191])|"            ..
         "(?:\237[\128-\159][\128-\191])|"            ..
  "(?:[\238-\239][\128-\191][\128-\191])|"            ..
         "(?:\240[\144-\191][\128-\191][\128-\191])|" ..
  "(?:[\241-\243][\128-\191][\128-\191][\128-\191])|" ..
         "(?:\244[\128-\143][\128-\191][\128-\191])|" ..
")*")
pat:find(("\000"):rep(1024*2))
shmuz commented 9 years ago

WinXP SP3 x86 Lua 5.1 PCRE 8.34 lrexlib (master) Works OK for me:

print ( pat:find(("\000"):rep(1024*2)) ) --> 1 2048
shmuz commented 9 years ago

I'd advise to add -DNO_RECURSE to CFLAGS when you build PCRE on Windows. It seems to be a stack overflow issue (related to PCRE rather than Lrexlib).

moteus commented 9 years ago

Just tested with -DNO_RECURSE and it works. But perfomance x4 slower :(

Thanks.