Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to abort an infinite loop

See original GitHub issue

(This might be related to my unusual settings described in #102)

mutmut got stuck on a mutation, and didn’t time it out. Reproduction:

$ mktmpenv -p python3.7
Running virtualenv with interpreter /usr/local/bin/python3.7
Using base prefix '/usr/local/pythonz/pythons/CPython-3.7.2'
/usr/local/pythonz/pythons/CPython-2.7.14/lib/python2.7/site-packages/ DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
New python executable in /usr/local/virtualenvs/tmp-b4da94a5634daf06/bin/python3.7
Also creating executable in /usr/local/virtualenvs/tmp-b4da94a5634daf06/bin/python
Installing setuptools, pip, wheel...done.
Requirement already up-to-date: pip in /usr/local/virtualenvs/tmp-b4da94a5634daf06/lib/python3.7/site-packages (19.0.3)
Requirement already up-to-date: setuptools in /usr/local/virtualenvs/tmp-b4da94a5634daf06/lib/python3.7/site-packages (40.8.0)
This is a temporary environment. It will be deleted when you run 'deactivate'.

$ git clone
Cloning into 'cog'...
remote: Enumerating objects: 657, done.
remote: Counting objects: 100% (657/657), done.
remote: Compressing objects: 100% (230/230), done.
remote: Total 657 (delta 458), reused 619 (delta 421), pack-reused 0
Receiving objects: 100% (657/657), 172.29 KiB | 574.00 KiB/s, done.
Resolving deltas: 100% (458/458), done.

$ cd cog

$ git checkout c1f605d7aaf3750568b7e7a5d784c081fff0fc97
Note: checking out 'c1f605d7aaf3750568b7e7a5d784c081fff0fc97'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at c1f605d mutmut settings

$ pip install tox==3.7.0
Collecting tox==3.7.0
  Using cached
Collecting six<2,>=1.0.0 (from tox==3.7.0)
  Using cached
Requirement already satisfied: setuptools>=30.0.0 in /usr/local/virtualenvs/tmp-b4da94a5634daf06/lib/python3.7/site-packages (from tox==3.7.0) (40.8.0)
Collecting pluggy<1,>=0.3.0 (from tox==3.7.0)
  Using cached
Collecting filelock<4,>=3.0.0 (from tox==3.7.0)
Collecting virtualenv>=1.11.2 (from tox==3.7.0)
  Downloading (2.0MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2.0MB 62kB/s
Collecting toml>=0.9.4 (from tox==3.7.0)
  Using cached
Collecting py<2,>=1.4.17 (from tox==3.7.0)
  Using cached
Installing collected packages: six, pluggy, filelock, virtualenv, toml, py, tox
Successfully installed filelock-3.0.10 pluggy-0.9.0 py-1.8.0 six-1.12.0 toml-0.10.0 tox-3.7.0 virtualenv-16.4.3

$ tox -e py27,py36
py27 create: /usr/local/virtualenvs/tmp-b4da94a5634daf06/cog/.tox/py27
py27 installdeps: coverage, pytest
py27 develop-inst: /usr/local/virtualenvs/tmp-b4da94a5634daf06/cog
py27 installed: DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.,atomicwrites==1.3.0,attrs==19.1.0,-e,coverage==4.5.3,funcsigs==1.0.2,more-itertools==5.0.0,pathlib2==2.3.3,pluggy==0.9.0,py==1.8.0,pytest==4.3.1,scandir==1.10.0,six==1.12.0
py27 run-test-pre: PYTHONHASHSEED='110312279'
py27 runtests: commands[0] | coverage run -m pytest
..............................................................................................................................                           [100%]
126 passed in 1.07 seconds
py36 create: /usr/local/virtualenvs/tmp-b4da94a5634daf06/cog/.tox/py36
py36 installdeps: coverage, pytest
py36 develop-inst: /usr/local/virtualenvs/tmp-b4da94a5634daf06/cog
py36 installed: atomicwrites==1.3.0,attrs==19.1.0,-e,coverage==4.5.3,more-itertools==6.0.0,pluggy==0.9.0,py==1.8.0,pytest==4.3.1,six==1.12.0
py36 run-test-pre: PYTHONHASHSEED='110312279'
py36 runtests: commands[0] | coverage run -m pytest
..............................................................................................................................                           [100%]
126 passed in 1.01 seconds
___________________________________________________________________________ summary ____________________________________________________________________________
  py27: commands succeeded
  py36: commands succeeded
  congratulations :)

$ pip install mutmut
Collecting mutmut
Collecting glob2 (from mutmut)
Collecting parso (from mutmut)
  Downloading (93kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 102kB 240kB/s
Collecting tri.declarative (from mutmut)
Collecting click (from mutmut)
  Downloading (81kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 81kB 172kB/s
Collecting pony (from mutmut)
  Downloading (267kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 276kB 206kB/s
Collecting junit-xml==1.8 (from mutmut)
Collecting tri.struct (from tri.declarative->mutmut)
Requirement already satisfied: six in /usr/local/virtualenvs/tmp-b4da94a5634daf06/lib/python3.7/site-packages (from junit-xml==1.8->mutmut) (1.12.0)
Building wheels for collected packages: mutmut, glob2, tri.declarative, pony, junit-xml, tri.struct
  Building wheel for mutmut ( ... done
  Stored in directory: /Users/ned/Library/Caches/pip/wheels/62/08/4e/9df18ef82cb934549753981bdb1388adba6bf389aac751abbf
  Building wheel for glob2 ( ... done
  Stored in directory: /Users/ned/Library/Caches/pip/wheels/1b/31/14/5a25a14e933674d8636bcc42af811c7eb87ea8f6e947c17273
  Building wheel for tri.declarative ( ... done
  Stored in directory: /Users/ned/Library/Caches/pip/wheels/d0/46/58/d03eec161d4de3eb451ce9ec673a831aafbdfaf6196669bed1
  Building wheel for pony ( ... done
  Stored in directory: /Users/ned/Library/Caches/pip/wheels/0e/b6/52/61130f0fffc57a62b94b36bf4807ec77b436e41c7bd7e17887
  Building wheel for junit-xml ( ... done
  Stored in directory: /Users/ned/Library/Caches/pip/wheels/c6/c5/65/5b166afb6eac87dc300368ec4d92f39502dd41cdc73056d49e
  Building wheel for tri.struct ( ... done
  Stored in directory: /Users/ned/Library/Caches/pip/wheels/c8/90/ae/a32ab1ed04cf48c87331f44710649a7c187ba2bf8eefaad891
Successfully built mutmut glob2 tri.declarative pony junit-xml tri.struct
Installing collected packages: glob2, parso, tri.struct, tri.declarative, click, pony, junit-xml, mutmut
Successfully installed click-7.0 glob2-0.6 junit-xml-1.8 mutmut-1.3.1 parso-0.3.4 pony-0.7.9 tri.declarative-1.2.1 tri.struct-2.5.7

$ mutmut run

- Mutation testing starting -

These are the steps:
1. A full test suite run will be made to make sure we
   can run the tests successfully and we know how long
   it takes (to detect infinite loops for example)
2. Mutants will be generated and checked

Mutants are written to the cache in the .mutmut-cache
directory. Print found mutants with `mutmut results`.

Legend for output:
πŸŽ‰ Killed mutants. The goal is for everything to end up in this bucket.
⏰ Timeout. Test suite took 10 times as long as the baseline so were killed.
πŸ€” Suspicious. Tests took a long time, but not long enough to be fatal.
πŸ™ Survived. This means your tests needs to be expanded.

mutmut cache is out of date, clearing it...
1. Running tests without mutations
β ΄ Running... Done

2. Checking mutants
β ™ 309/464  πŸŽ‰ 267  ⏰ 0  πŸ€” 0  πŸ™ 42^C

$ mutmut show 309
--- cogapp/
+++ cogapp/
@@ -512,7 +512,7 @@
                 # them, compute the md5 hash of the old output.
                 previous = ""
                 hasher = hashlib.md5()
-                while l and not self.isEndOutputLine(l):
+                while l and  self.isEndOutputLine(l):
                     if self.isBeginSpecLine(l):
                         raise CogError("Unexpected '%s'" % self.options.sBeginSpec,
                             file=sFileIn, line=fIn.linenumber())

$ more setup.cfg
addopts = -q -rfe

paths_to_mutate = cogapp/
runner = sh -c '.tox/py27/bin/pytest -x && .tox/py36/bin/pytest -x'

It took about 5 minutes for mutmut to run the first 308 mutants, and I waited about 5 minutes before Ctrl-C’ing number 309.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

ghostcommented, Feb 6, 2020

Just to add my two cents: I also observed that the readline call on the stdout file handle blocks the entire main mutmut process. From my cursory understanding of the code, the stdout is only consumed to enable the progress spinner.

I simply patched my copy to remove the β€œreadline” call completely and I am now just calling the callback every 0.05s while the subprocess is running:

    while process.returncode is None:
            if == 'nt':  # pragma: no cover
                line = stdout.readline()
                # windows gives readline() raw stdout as a b''
                # need to decode it
                line = line.decode("utf-8")
                if line:  # ignore empty strings and None
                #line = stdout.readline()
                #if not line:
                #    break

You can also now adjust the spinner’s smoothness and are no longer dependent on your test runner to give you a smooth 20Hz spinner.

atugushevcommented, May 20, 2020

Here is the fix in #171. Any reviews and tests are welcomed! Thanks! πŸ™

Read more comments on GitHub >

github_iconTop Results From Across the Web

rewrite_tag claims Match causes infinite loop i fluentbit 1.8
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be...
Read more >
JAVA : Why does the following infinite loop terminate without ...
First of all, both snippets are not infinite loops, since i will become negative once it passes Integer.MAX_VALUE .
Read more >
Any way to abort an infinite recursion loop without ... - Reddit
Every time my code results in an infinite loop I have to comment out the call to the function, save, then close OpenSCAD....
Read more >
What happens in an infinite loop? - Codecademy
Your computer most likely locked up because the infinite loop made the browser you were using unstable.
Read more >
What to Do if Your Program Infinite Loops
A common error in programs is loops that never terminate. ... First, let me talk about the situation where your program is infinite...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found