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

VM attempts to parse IP addr as float #590

Open
zane-deg opened this issue Sep 28, 2021 · 1 comment
Open

VM attempts to parse IP addr as float #590

zane-deg opened this issue Sep 28, 2021 · 1 comment
Assignees
Labels
bug This is considered a bug and shall get fixed mtail-Language/VM Issues related to the mtail language, compiler, or VM

Comments

@zane-deg
Copy link
Contributor

zane-deg commented Sep 28, 2021

Summary

Certain regex patterns when used to capture an IP address are causing mtail to try and parse IP addresses as a float:

Runtime error: strconv.ParseFloat: parsing "10.0.0.1": invalid syntax

I have included an mtail program below that can recreate the problem along with a similar program that does not cause the problem. Curiously this seems to only occur when creating a histogram metric.

Steps to reproduce:

  1. mtail --one_shot --progs broken.mtail --logs example.log -logtostderr
  2. Verify Runtime error occurs
  3. mtail --one_shot --progs working.mtail --logs example.log -logtostderr
  4. Verify program runs as expected

mtail --version

mtail version 3.0.0-rc47 git revision 5e0099f843e4e4f2b7189c21019de18eb49181bf go version go1.16.5 go arch amd64 go os darwin

AST Type Dump

I have attempted to get a type dump by running:

  • mtail --one_shot --progs broken.mtail --logs example.log --dump_ast_types --log_dir output
  • mtail --one_shot --compile_only --progs broken.mtail --logs example.log --dump_ast_types --log_dir output

Neither has resulted in a log beyond:

Log file created at: 2021/09/28 15:20:02
Running on machine: MY_MACHINE_NAME
Binary: Built with gc go1.16.5 for darwin/amd64
Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg

Let me know if I am running this command incorrectly and I can submit the appropriate log.

Thanks!


example.log

10.0.0.1 total_time=5
10.0.0.2 total_time=742

broken.mtail

histogram example_name buckets 1, 2 by instance

/^(?P<ip>[\d\.]+) total_time=(?P<total>\d+)/ {
  example_name[$ip] = $total / 1000.0
}

working.mtail

histogram example_name buckets 1, 2 by instance

/^(?P<ip>\d+(?:\.\d+){3}) total_time=(?P<total>\d+)/ {
  example_name[$ip] = $total / 1000.0
}
@jaqx0r
Copy link
Contributor

jaqx0r commented Sep 29, 2021

Thankyou for the detailed report and reproduction steps!

I think the bug is that mtail looks at the possible content of the IP in broken.mtail and infers that it could be a float, but doesn't note that there can only be a single decimal point in it, while the field accepts more than one. The second form makes the repetition explicit, so it's partially working in that it can tell that there's more than one decimal point matched in working.mtail.

@jaqx0r jaqx0r added bug This is considered a bug and shall get fixed mtail-Language/VM Issues related to the mtail language, compiler, or VM labels Sep 29, 2021
@jaqx0r jaqx0r self-assigned this Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is considered a bug and shall get fixed mtail-Language/VM Issues related to the mtail language, compiler, or VM
Projects
None yet
Development

No branches or pull requests

2 participants