Skip to content

Hit SIGSEGV because of the increased Difficulty.#1

Open
Kangmo wants to merge 1 commit intoetclabscore:masterfrom
Kangmo:master
Open

Hit SIGSEGV because of the increased Difficulty.#1
Kangmo wants to merge 1 commit intoetclabscore:masterfrom
Kangmo:master

Conversation

@Kangmo
Copy link
Copy Markdown

@Kangmo Kangmo commented May 9, 2021

Describe the bug

Hit SIGSEGV because of the increased Difficulty. The issue is reproed in Linux environment only for now.

To Reproduce
Steps to reproduce the behavior:

Run ethminer --cuda --pool http://localhost:8080

On Windows, it does not crash, but prints the following string.
i 15:12:31 Epoch : 422 Difficulty : 386.91 �

On CentOS with gcc-9, it crashes with SIGSEGV. Attached the stdout messages.
1.txt

Expected behavior
The SIGSEGV should not happen, but show Th unit when printing out the difficulty.

Environment (please complete the following information):

  • CentOS 7, gcc-9, cuda 11.3
  • Ethminer Version 0.18.0, 0.19.0, main
  • Ethminer options used: --cuda --pool http://localhost:8080

Additional context
The fix is as follows. Reproed in gdb env and it was tested that the code fixes the issue.

diff --git a/libdevcore/CommonData.cpp b/libdevcore/CommonData.cpp
index 7dae6fccb..6c5d4d50d 100644
--- a/libdevcore/CommonData.cpp
+++ b/libdevcore/CommonData.cpp
@@ -176,13 +176,13 @@ std::string dev::getScaledSize(double _value, double _divisor, int _precision, s

 std::string dev::getFormattedHashes(double _hr, ScaleSuffix _suffix, int _precision)
 {
-    static string suffixes[] = {"h", "Kh", "Mh", "Gh"};
+    static string suffixes[] = {"h", "Kh", "Mh", "Gh", "Th", "Ph"};
     return dev::getScaledSize(_hr, 1000.0, _precision, suffixes, 6, _suffix);
 }

 std::string dev::getFormattedMemory(double _mem, ScaleSuffix _suffix, int _precision)
 {
-    static string suffixes[] = {"B", "KB", "MB", "GB"};
+    static string suffixes[] = {"B", "KB", "MB", "GB", "TB", "PB"};
     return dev::getScaledSize(_mem, 1024.0, _precision, suffixes, 6, _suffix);
 }

The issue is reproed in Linux environment only for now.

How to repro:

Run ethminer  --cuda --pool http://localhost:8080

On Windows, it does not crash, but prints random string for the unit of hash while it prints difficulty.

On CentOS with gcc-9, it crashes with SIGSEGV.

Root cause:
dev::getFormattedHashes has only up to Gh, not Th.

Fix:
Add Th, Ph to dev::getFormattedHashes.
Also add TB, PB to dev::getFormattedMemory to eliminate future problems.
obykk pushed a commit to obykk/etcminer that referenced this pull request Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant