Pylint hang 27/06/14

23 views
Skip to first unread message

Jeremy Morse

unread,
Jun 27, 2014, 7:53:52 AM6/27/14
to srobo...@googlegroups.com
Hi,

Looking at the server today, I found six pylint processes running at
100% CPU each, with about 15 minutes CPU time accumulated for each
process. I checked with Sam and he hasn't been benchmarking today (yet).

Process start time and so forth indicates these processes were started
today; I initially thought it was HSO as they've had some activity
today, but the project name being linted was 'Team RT', which comes from
Tauntons.

Stracing the culprit processes shows that pylint was doing nothing: no
IO, no syscalls. I grabbed some of the files that were being linted,
after which four more pylint processes turned up, so I started killing
them. Since then, two more have popped up and been killed.

I don't want to attach the code here as it belongs to the team, but if
you inspect team-TTN's 'Team RT' repo, you'll find that line 146 of
robot.py contains:

motorStop()

Followed by 17164 spaces. Applying pylint locally to this hangs, and
when given SIGINT, produces the following stacktrace (mangled by
copy+paste, sorry):

jmorse at leviticus in ~/lint
$ pylint robot.py
No config file found, using default configuration
^CTraceback (most recent call last):
File "/usr/bin/pylint", line 4, in <module>
lint.Run(sys.argv[1:])
File "/usr/lib/pymodules/python2.7/pylint/lint.py", line 879, in __init__
linter.check(args)
File "/usr/lib/pymodules/python2.7/pylint/lint.py", line 502, in check
self.check_astng_module(astng, walker, rawcheckers)
File "/usr/lib/pymodules/python2.7/pylint/lint.py", line 564, in
check_astng_module
self.process_module(astng)
File "/usr/lib/pymodules/python2.7/pylint/checkers/__init__.py", line
124, in process_module
self.process_tokens(tokenize.generate_tokens(stream.readline))
File "/usr/lib/pymodules/python2.7/pylint/lint.py", line 372, in
process_tokens
match = OPTION_RGX.search(line)
KeyboardInterrupt

Which suggests to me that a regex (looking for '# pylint:' options)
being applied to such a huge line is causing that hang. Observe that
just 17,000 characters on a line is causing a hang of at least 15
minutes on the server. Removing the whitespace prevents the hang from
occurring.

~

Closer inspection shows that this line was only introduced today, and
the project TTN were using at the competition did not contain that line.
It's still super concerning though. IMO enforcing a max-line limit on
competitors code isn't unreasonable if this is going to be a problem.

I've emailed the teacher at Tauntons about this to see if he can shed
any light on the matter; if I hear nothing back, I'll quietly trim that
line overnight.

--
Thanks,
Jeremy

signature.asc

Sam Phippen

unread,
Jun 27, 2014, 8:35:37 AM6/27/14
to srobo...@googlegroups.com
> We should make the IDE strip all trailing whitespace on behalf of the users.

Rob Spanton

unread,
Jun 27, 2014, 10:53:01 AM6/27/14
to srobo...@googlegroups.com
Hey,

Jeremy wrote:
> Which suggests to me that a regex (looking for '# pylint:' options)
> being applied to such a huge line is causing that hang. Observe that
> just 17,000 characters on a line is causing a hang of at least 15
> minutes on the server. Removing the whitespace prevents the hang from
> occurring.

Sam Phippen wrote:
> We should make the IDE strip all trailing whitespace on behalf of the users.

Sounds reasonable.

Another thing we could also do is limit the runtime of the pylint
process.

Cheers,

Rob
signature.asc

Peter Law

unread,
Jun 27, 2014, 2:10:02 PM6/27/14
to Student Robotics
Hi,

Jeremy wrote:
> *pylint hangs*

> Which suggests to me that a regex (looking for '# pylint:' options)
> being applied to such a huge line is causing that hang. Observe that
> just 17,000 characters on a line is causing a hang of at least 15
> minutes on the server. Removing the whitespace prevents the hang from
> occurring.

I can't reproduce this locally on my machine using their source code.
Admitedly I'm running a much more powerful machine than badger, but
I'm also wondering if having a newer pylint (1.1.0 vs 0.26) results in
it dealing with this much better. (The regex is different between
badger's and my Ubuntu's versions, but I can't find any mention of
badger's one in the pylint history, which is odd).

A quick google suggests that there isn't a way to avoid it searching
for that pattern, but the other suggested fixes should mean that that
doesn't matter anyway.

> IMO enforcing a max-line limit on
> competitors code isn't unreasonable if this is going to be a problem.

Presumably you mean a max file-length or line-length limit, rather
than a line limit here?

Sam wrote:
> We should make the IDE strip all trailing whitespace on behalf of the users.

We might as well do this client side, since we can't easily force this
in commits they make outside the IDE.

Rob wrote:
> Another thing we could also do is limit the runtime of the pylint
> process.

Both of these are certainly do-able. I'll have a look this weekend if
I find time.

Peter

Jeremy Morse

unread,
Jun 27, 2014, 2:40:30 PM6/27/14
to srobo...@googlegroups.com
Hi,

On 27/06/14 19:09, Peter Law wrote:
> I can't reproduce this locally on my machine using their source code.
> Admitedly I'm running a much more powerful machine than badger, but
> I'm also wondering if having a newer pylint (1.1.0 vs 0.26) results in
> it dealing with this much better. (The regex is different between
> badger's and my Ubuntu's versions, but I can't find any mention of
> badger's one in the pylint history, which is odd).

My main PC is super-fast and still hangs, it has pylint 0.25.1. I just
pulled in the latest pylint from debian/testing, v1.2.1, which completes
almost immediately. So, it's definitely fixed in later versions.

>> IMO enforcing a max-line limit on
>> competitors code isn't unreasonable if this is going to be a problem.
>
> Presumably you mean a max file-length or line-length limit, rather
> than a line limit here?

Ah, the latter, yes. Thanks for the correction. (It's arbitrary, but
effective, and likely has low impact).

--
Thanks,
Jeremy

signature.asc

Peter Law

unread,
Jul 5, 2014, 10:14:54 AM7/5/14
to Student Robotics
> Rob wrote:
>> Another thing we could also do is limit the runtime of the pylint
>> process.

I approached this one first as it's the more robust solution, and the
fix [1] is now merged.

Thanks,
Peter

[1] https://www.studentrobotics.org/cgit/cyanide.git/commit/?id=75b57f2498cc6c3bad62c834a29bc8e940f9f775
Reply all
Reply to author
Forward
0 new messages