"bus error" on Mac OS with specific test file and regex
fizbin opened this issue · comments
I found this when using ag
to scan a whole directory of python source for a particular code pattern, then narrowed down the reproducible case to the smallest section of stuff-that-looks-like-source that I could. I did not attempt to minimize the regex, so you get that in all its original messiness.
Output of uname -a
on my machine, with the machine name censored: (It's an Apple M1 Max)
Darwin MachineNameHere 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64
Note that ag
does not bus error when called with test_file
as a second argument; the bus error only happens when it reads it from the directory. (Though since it does bus error when run on the whole original source file explicitly, it's likely that a larger test_file
could trigger this even when called with the file as a second argument)
Transcript of error:
% brew upgrade ag
Warning: ag 2.2.0 already installed
% ag --version
ag version 2.2.0
Features:
+jit +lzma +zlib
% ls -a -F
./ ../ test_file
% cat test_file
WordWith_re_InIt, # here's a comment with a stray apostrophe
XXXXXXXXX, # other comment
)
BLAH_BLAH_BLAH_IS_IT_IMPORTANT_MAYBE: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX = {
"keyone": ["value1"]
}
DEFAULT_BIG_DICTIONARY_OF_STUFF: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX = {
"keytwo": ZZZZZZZZZZ.YYYYYYYYYYYYYYYYY,
"keythree": ZZZZZZZZZZ.YYYYYYYYYYYYYYYYY,
"keyfour": ZZZZZZZZZZ.YYYYYYYYYYYYYYYYY,
"keyfive": ZZZZZZZZZZ.YYYYYYYYYYYYYYYYY,
"keysix": ZZZZZZZZZZ.YYYYYYYYYYYYYYYYY,
% ag 're[^\x27"]*(?:(?:\x27(?:[^\\\x27]|\\.)*\x27|"(?:[^\\"]|\\.)*")[^\x27"]*)*(?:\x27(?:[^\\\x27]|\\.)*|"(?:[^\\"]|\\.)*){'
zsh: bus error ag
Attached is the test file. It gets a bus error no matter what the filename is. (I had to rename the file to test_file.txt
to attach it in github)