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
toplev crashes on wrong float literal #43
Comments
Yes, it looks like locale. However it's really a perf bug too. If someone uses the more standard -x, instead of -x ; you would end up with an extra field. But if perf was fixed to do the output always with ., then the locale aware float parser would break, because the meaning of comma and dot is switched in your locale, with comma meaning thousand separator. So I ended up just replacing , with . before doing the conversion. |
Right, I totally forgot about a thousand separator. Thanks for the fix :). |
Some locales print floating point numbers with a comma instead of a dot. This causes problems with CSV mode because it causes extra false CSV fields. Force the numeric locale to be always C in CSV mode. Before: $ LC_ALL=pl_PL.utf8 perf stat -x, true 0,399472,,task-clock,399472,100,00 <---- extra bogus field ... After: $ LC_ALL=pl_PL.utf8 ./obj-perf/perf stat -x, true 0.338422,,task-clock,338422,100.00 Originally reported in andikleen/pmu-tools#43 Signed-off-by: Andi Kleen <ak@linux.intel.com>
Everything below was run as root.
Below is the result of
perf stat ...
:I am not sure what's the case, but maybe locale?
The
/usr/bin/python
version (shouldn't you use/usr/bin/env python
instead?):Probably the issue can be solved setting locale in Python to the system one:
So in the end it seems that
locale.atof
should be used instead offloat
when castingstr
tofloat
.The text was updated successfully, but these errors were encountered: