question-mark
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.

Unresponsive with 100% CPU

See original GitHub issue

I was trying out solidity-coverage today but running into issues testing it out. I have ~17 contracts, and after “Instrumenting…” the process pegs one CPU core at 100% and never seems to finish(waited a bit over 1 hour).

How can I go about debugging this? I’ve tried the traditional node DEBUG env var with no useful output.

DEBUG="*" ./node_modules/.bin/solidity-coverage

Here’s my .solcover.js file. I have tried without specifying port, testCommand, and norpc as well(also, ganache appears to not receive any transactions during this process).

module.exports = {
    port: 8545,
    testCommand: './node_modules/.bin/truffle test --network dev',
    norpc: true,
    copyNodeModules: true,
    skipFiles: ['Test.sol']
};

The process can not be terminated through a keyboard interrupt(ctrl+c) either. I’m running this on an Arch Linux system, if that helps. Let me know if I can provide any more information.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:34 (19 by maintainers)

github_iconTop GitHub Comments

3reactions
h3ph4est7scommented, Jul 12, 2018

Hi @vs77bb the project type is Traditional so its 1 worker at a time i cannot participate if there is a way that i don’t currently know please inform me 😄. Also i wanted to clarify that i already have the diagnosis due to a project im working on and using oraclize service with solidity-coverage and i wasn’t targeting on the bounty in the first place (it came out as a bonus) also i want to apologize to @mttmartin for the highjack.

3reactions
h3ph4est7scommented, Jul 11, 2018

The exclusion issue arrise when the line https://github.com/sc-forks/solidity-coverage/blob/a40ba7b1b4c4fe03352eb4899aa27931a6734f6b/lib/app.js#L390 in postProcessPure does not properly check for excluded files. #259 is addressing this issue by adding an exclusion file/folder check. As for the bug itself the process “hangs” (in the matter of fact is working) because of the unbracketed singleton statement parser at https://github.com/sc-forks/solidity-coverage/blob/a40ba7b1b4c4fe03352eb4899aa27931a6734f6b/lib/preprocessor.js#L40 is too slow when it comes to parsing large contracts the main issue is the loop using: https://github.com/sc-forks/solidity-coverage/blob/a40ba7b1b4c4fe03352eb4899aa27931a6734f6b/lib/preprocessor.js#L45 witch takes a lot of time to parse all the contract in every pass. The aforementioned claim can be verified by applying the following patch:

--- lib/preprocessor.js (revision a40ba7b1b4c4fe03352eb4899aa27931a6734f6b)
+++ lib/preprocessor.js (date 1531305439000)
@@ -42,7 +42,10 @@
 
   while (keepRunning) {
     try {
+      console.time('parse');
       const ast = SolidityParser.parse(contract);
+      console.log('length: ' + contract.length);
+      console.timeEnd('parse');
       keepRunning = false;
       SolExplore.traverse(ast, {
         enter(node, parent) { // eslint-disable-line no-loop-func
@@ -84,6 +87,7 @@
         },
       });
     } catch (err) {
+      console.log(err);
       contract = err;
       keepRunning = false;
     }

and getting this output:

length: 46508
parse: 41473.762ms
length: 46500
parse: 41236.352ms
length: 46502
parse: 43498.465ms
length: 46504
parse: 41831.958ms
length: 46506
parse: 40028.604ms

and after approx. 40 * 40 / 60 = 26,66 minutes later

length: 46544
parse: 38760.110ms
length: 46540
parse: 41115.355ms
length: 46542
parse: 38606.990ms
length: 46544
parse: 36695.497ms
length: 46546
parse: 47062.380ms

this indicates that every iteration take approximately 40 seconds (in my machine), multiply that with the number of required passes and the result is really time consuming.

The conditions are triggered when using usingOraclize.sol (SHA256: 79283d8e5f4f30fe33c6b0ab2296531bdd159f19438ec18fe9ebae2a5bc7edae) file at: https://github.com/sc-forks/solidity-coverage/blob/a40ba7b1b4c4fe03352eb4899aa27931a6734f6b/lib/app.js#L393

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Fix an Issue When CPU at 100% All the Time on ...
One quick way to get rid of this issue is to end the processes that take up high CPU usage simply. You can...
Read more >
8 Useful Solutions to Fix Your CPU 100% in Windows 10/11
Sometimes your CPU is running at 100% and the speed of your computer becomes slow. This post will provide 8 solutions for you...
Read more >
100% CPU Usage in Windows? Here's How to Fix it
It's a common problem that's, luckily, not usually too hard to solve. Here are several fixes for the 100% CPU usage problem in...
Read more >
How to Fix High CPU Usage in Windows - MakeUseOf
Restart the WMI Provider Host to Fix High CPU Usage · Press Windows key + S, input Services, and press Enter. · In...
Read more >
Windows explorer not responding very high cpu usage with no ...
1. Press Windows Key + R and type SYSDM.CPL in Run. Click OK or press Enter key. 2. In System Properties window, switch...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found