See https://unix.stackexchange.com/questions/398223/ for how to replicate this. Some investigation reveals that this is apparently down to the pmatch object in the procline() function not being used properly. In the outer loop, it is being used to track the start and end position within the current input line. However, if multiple patterns are provided, in the inner loop it is overwritten by the first call to fastexec()/regexec() and not reinitialized with st and l->len for the next. The (re)initialization code for pmatch.rm_so and pmatch.rm_eo needs to be moved down into the inner loop, so that it is set correctly for every pattern, not just for the first one. This also means that the if (st == (size_t)pmatch.rm_so) code in the outer loop is probably wrong, too, as that will only detect the output of the last fastexec()/regexec() call for the last of multiple patterns. Perhaps there should be one pmatch object per pattern.
Hi, Do you know offhand if this reproduces on -CURRENT (bsdgrep 2.6.0-FreeBSD)? I've made some major overhauls to bsdgrep that haven't hit stable/10 yet.
Does not reproduce on -current using the provided instructions: % cat file file types extensions % cat stopwords i file types % grep -vwFf stopwords file extensions %
(In reply to Ed Maste from comment #2) Excellent, I'll go through tomorrow and pinpoint the commit(s) that would've fixed this one. I think I'll have some time to MFC everything to stable/10 soon.
base r316477? I am not using -CURRENT. I'll update StackExchange if you confirm which revision it is that fixed this.
(In reply to Jonathan de Boyne Pollard from comment #4) Indeed, base r316477 fixed this particular error. There were some further fixes for -w -v matching errors in base r317665, but this one was addressed in the former.
I'm going to go ahead and close this as duplicate of PR 209116 (bsdgrep -Fxf failing if earlier non-match is a sub-prefix of the actual match) -- thanks for your report and detailed assessment! *** This bug has been marked as a duplicate of bug 209116 ***