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

Crash when regex without body is used #1289

Open
dmig opened this issue Jul 24, 2024 · 2 comments
Open

Crash when regex without body is used #1289

dmig opened this issue Jul 24, 2024 · 2 comments
Labels

Comments

@dmig
Copy link
Sponsor

dmig commented Jul 24, 2024

lnav version
v0.12.2, Macos

Describe the bug
I created a custom format file with 2 regexes, one matches subset of messages from another. Since lnav doesn't stop at first matched regex (shouldn't this be a default behavior?), I added a negative lookahead to one of them.
lnav silently stopped loading. When started with -WC, it reports a crash.
Without negative lookahead in regex lnav runs, but more generic regex is always used. When started with -WC, it reports a warning about two matching regexes:

⚠ warning: invalid log format: “test”
   reason: sample is matched by more than one regex: request_profiler, std
 --> /Users/dmig/.config/lnav/formats/installed/test.json:55
 | [new-dev][28245.8575077376] [2024-07-24 11:59:24,071] [INFO] [request_profiler] [-] [GET] [http://new-dev.localhost:5000/api/v1/globalsearch/Polytetrafluoroethylene?filter=all&page=1] [START]
 =   help: log format regexes must match a single type of log message
⚠ warning: invalid log format: “test”
   reason: sample is matched by more than one regex: request_profiler, std
 --> /Users/dmig/.config/lnav/formats/installed/test.json:59
 | [new-dev][28245.8575077376] [2024-07-24 11:59:26,528] [INFO] [request_profiler] [#5:3005] [GET] [http://new-dev.localhost:5000/api/v1/globalsearch/Polytetrafluoroethylene?filter=all&page=1] [2.4576] [FINISH]
 =   help: log format regexes must match a single type of log message

To Reproduce
Steps to reproduce the behavior:

  1. install attached format test.json
  2. try to open attached log file test.log as lnav test.log, lnav -WC test.log
  3. edit test.json, regex.std.pattern: remove (?!request_profiler) substring
  4. repeat step 2

Crash log:
crash-2024-07-24-14-15-06.40537.log

@dmig dmig added the bug label Jul 24, 2024
@dmig
Copy link
Sponsor Author

dmig commented Jul 24, 2024

Ok, I discovered the reason wrong: it's not the backtrack, it's the regex without body.
But shouldn't crash anyway.

@dmig dmig changed the title Crash when regex backtracking is used Crash when regex without body is used Jul 24, 2024
@tstack
Copy link
Owner

tstack commented Aug 1, 2024

It looks like it's because a module field is defined with a body field. The validator should check for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants