tstack / lnav

Log file navigator
http://lnav.org
BSD 2-Clause "Simplified" License
7.83k stars 312 forks source link

Crash with a specific regex pattern #1288

Open mpeter50 opened 2 months ago

mpeter50 commented 2 months ago

lnav version v0.12.2

Describe the bug When I use a specific regex pattern, lnav crashes on startup. The crash happens before patterns would be validated against the samples.

The regex pattern in question is the following:

^(?J:(?:(?<timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d+) (?:(?<level>[A-Z]+)  \[(?<module>[\w \/]+)\] (?<component>[\w.]+): (?<body>.*)|(?:(?:\^){3} \d+ similar messages omitted (?:\^){3})))|(?:(?:(?:[\w.]+(?<level>Exception):)|(?:\   at)) .*)|(?:(?:\*{3} .*)|(?:Starting I2P.*)|(?:\[startapp].*)))$

To Reproduce Steps to reproduce the behavior:

  1. Take the i2p_router_log.json from this commit: https://github.com/tstack/lnav/pull/1286/commits/ce88dce5567a548749747fc5df252b664962a98d (this should be the same as the above, but doubly escaped for JSON)
  2. Put that in a new format definition
  3. Start lnav for any log file, or without one with lnav -N

I'll send the crash log in email.

This pattern is so complicated for the reason that the software it was made for produces several different kinds of log lines. The top level group is for setting a regex flag. There are 3 variants in it, each in its own group, for the primary log lines, Java exceptions, and the log format that is used at startup. If any one of the first 2 variants are taken out, lnav does not crash anymore. That way the pattern looks like the following: Without the primary format:

^(?J:(?:(?:(?:[\w.]+(?<level>Exception):)|(?:\  at)) .*)|(?:(?:\*{3} .*)|(?:Starting I2P.*)|(?:\[startapp].*)))$

Without exception recognition (used for marking errors):

^(?J:(?:(?<timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d+) (?:(?<level>[A-Z]+)  \[(?<module>[\w \/]+)\] (?<component>[\w.]+): (?<body>.*)|(?:(?:\^){3} \d+ similar messages omitted (?:\^){3})))|(?:(?:\*{3} .*)|(?:Starting I2P.*)|(?:\[startapp].*)))$