在Windows上使用GHC时,以下代码崩溃。它在Linux上完美运行。
这有什么意义还是有错误?
module Main where
import qualified Text.Regex as Re -- from regex-compat
import Debug.Trace
main :: IO ()
main = do
putStr $ cleanWord "jan"
putStr $ cleanWord "dec"
putStr $ cleanWord "jun" -- crashes here
cleanWord :: String -> String
cleanWord word_ =
let word = trace (show word_) word_ in
let re = Re.mkRegexWithOpts "(jun|jul|aug|sep|oct|nov|dec)" True False in
Re.subRegex re word ""
一些其他细节
stack
答案 0 :(得分:0)
围绕正则表达式进行洗牌避免了这种情况下的错误。
这对我现在很好用
let re = Re.mkRegexWithOpts "(jul|aug|sep|oct|jun|nov|dec)" True False in
即。将jun
移到正则表达式的末尾。不是特别令人满意,但它有效,这意味着我可以继续。
@ Zeta的评论表明这是底层库的错误
这是一个错误,可能在regex-posix中,因为它的差异 从1994年开始包含底层BSD正则表达式库。在sslow中,a
将访问无效的内存地址(-1(%rdx),rdx = 0)