Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.

Commit 93ecd93

Browse files
committed
Merge remote-tracking branch 'origin/master' into release/0.14
2 parents 42953dc + e4fd834 commit 93ecd93

File tree

11 files changed

+50
-77
lines changed

11 files changed

+50
-77
lines changed

cmake/EthCompilerSettings.cmake

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,26 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
2525

2626
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
2727

28+
# declare Windows XP requirement
29+
# undefine windows.h MAX & MIN macros because they conflict with std::min & std::max functions
30+
# disable unsafe CRT Library functions warnings
31+
add_definitions(/D_WIN32_WINNT=0x0501 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS)
32+
2833
# enable parallel compilation
29-
# specify Exception Handling Model in msvc
34+
# specify Exception Handling Model
3035
# enable LTCG for faster builds
31-
# disable unknown pragma warning (4068)
32-
# disable unsafe function warning (4996)
33-
# disable decorated name length exceeded, name was truncated (4503)
34-
# disable conversion from 'size_t' to 'type', possible loss of data (4267)
35-
# disable qualifier applied to function type has no meaning; ignored (4180)
36-
# disable C++ exception specification ignored except to indicate a function is not __declspec(nothrow) (4290)
37-
# disable conversion from 'type1' to 'type2', possible loss of data (4244)
38-
# disable forcing value to bool 'true' or 'false' (performance warning) (4800)
39-
# declare Windows XP requirement
40-
# undefine windows.h MAX & MIN macros because they cause conflicts with std::min & std::max functions
41-
add_compile_options(/MP /EHsc /GL /wd4068 /wd4996 /wd4503 /wd4267 /wd4180 /wd4290 /wd4244 /wd4800 -D_WIN32_WINNT=0x0501 /DNOMINMAX)
42-
# disable empty object file warning
43-
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /LTCG /ignore:4221")
36+
# disable conversion from 'size_t' to 'type', possible loss of data (C4267)
37+
# disable C++ exception specification ignored except to indicate a function is not __declspec(nothrow) (C4290)
38+
# disable decorated name length exceeded, name was truncated (C4503)
39+
add_compile_options(/MP /EHsc /GL /wd4267 /wd4290 /wd4503)
40+
41+
# enable LTCG for faster builds
42+
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /LTCG")
43+
4444
# enable LTCG for faster builds
45-
# enable RELEASE so that the executable file has its checksum set
4645
# enable unused references removal
47-
# warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification
48-
# warning LNK4099: pdb was not found with lib
49-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG /RELEASE /OPT:REF /OPT:ICF /ignore:4099,4075")
46+
# enable RELEASE so that the executable file has its checksum set
47+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG /OPT:REF /OPT:ICF /RELEASE")
5048
else ()
5149
message(WARNING "Your compiler is not tested, if you run into any issues, we'd welcome any patches.")
5250
endif ()
@@ -55,4 +53,3 @@ set(SANITIZE NO CACHE STRING "Instrument build with provided sanitizer")
5553
if(SANITIZE)
5654
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=${SANITIZE}")
5755
endif()
58-

ethminer/MinerAux.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class MinerCLI
334334
{
335335
m_show_hwmonitors = true;
336336
if ((i + 1 < argc) && (*argv[i + 1] != '-'))
337-
m_show_power = (bool)atoi(argv[++i]);
337+
m_show_power = atoi(argv[++i]) != 0;
338338
}
339339
else if ((arg == "--exit"))
340340
{
@@ -870,7 +870,8 @@ class MinerCLI
870870
WorkPackage current = WorkPackage(genesis);
871871

872872

873-
map<uint64_t, WorkingProgress> results;
873+
vector<uint64_t> results;
874+
results.reserve(_trials);
874875
uint64_t mean = 0;
875876
uint64_t innerMean = 0;
876877
for (unsigned i = 0; i <= _trials; ++i)
@@ -890,16 +891,19 @@ class MinerCLI
890891
auto rate = mp.rate();
891892

892893
cout << rate << endl;
893-
results[rate] = mp;
894+
results.push_back(rate);
894895
mean += rate;
895896
}
896-
int j = -1;
897-
for (auto const& r: results)
898-
if (++j > 0 && j < (int)_trials - 1)
899-
innerMean += r.second.rate();
900-
innerMean /= (_trials - 2);
901-
cout << "min/mean/max: " << results.begin()->second.rate() << "/" << (mean / _trials) << "/" << results.rbegin()->second.rate() << " H/s" << endl;
902-
cout << "inner mean: " << innerMean << " H/s" << endl;
897+
sort(results.begin(), results.end());
898+
cout << "min/mean/max: " << results.front() << "/" << (mean / _trials) << "/" << results.back() << " H/s" << endl;
899+
if (results.size() > 2) {
900+
for (auto it = results.begin()+1; it != results.end()-1; it++)
901+
innerMean += *it;
902+
innerMean /= (_trials - 2);
903+
cout << "inner mean: " << innerMean << " H/s" << endl;
904+
}
905+
else
906+
cout << "inner mean: n/a" << endl;
903907

904908
exit(0);
905909
}

libdevcore/Common.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323

2424
#pragma once
2525

26-
// way to many unsigned to size_t warnings in 32 bit build
27-
#ifdef _M_IX86
28-
#pragma warning(disable:4244)
29-
#endif
30-
3126
#include <map>
3227
#include <unordered_map>
3328
#include <vector>

libethash-cuda/CUDAMiner.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -508,17 +508,8 @@ void CUDAMiner::search(
508508
found_count = SEARCH_RESULTS;
509509
for (unsigned int j = 0; j < found_count; j++) {
510510
nonces[j] = nonce_base + buffer->result[j].gid;
511-
if (s_noeval) {
512-
uint32_t* m = (uint32_t *)(mixes + j);
513-
m[0] = buffer->result[j].mix[0] ;
514-
m[1] = buffer->result[j].mix[1] ;
515-
m[2] = buffer->result[j].mix[2] ;
516-
m[3] = buffer->result[j].mix[3] ;
517-
m[4] = buffer->result[j].mix[4] ;
518-
m[5] = buffer->result[j].mix[5] ;
519-
m[6] = buffer->result[j].mix[6] ;
520-
m[7] = buffer->result[j].mix[7] ;
521-
}
511+
if (s_noeval)
512+
memcpy(mixes[j].data(), (void *)&buffer->result[j].mix, sizeof(buffer->result[j].mix));
522513
}
523514
}
524515
}

libethash-cuda/CUDAMiner.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
1717

1818
#pragma once
1919

20-
#define _CRT_SECURE_NO_WARNINGS
21-
2220
#include <time.h>
2321
#include <functional>
2422
#include <libethash/ethash.h>

libethcore/Farm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class Farm: public FarmFace
208208
m_lastProgresses.push_back(p);
209209

210210
// We smooth the hashrate over the last x seconds
211-
int allMs = 0;
211+
uint64_t allMs = 0;
212212
for (auto const& cp : m_lastProgresses)
213213
allMs += cp.ms;
214214

@@ -439,7 +439,7 @@ class Farm: public FarmFace
439439
bool b_lastMixed = false;
440440

441441
std::chrono::steady_clock::time_point m_lastStart;
442-
int m_hashrateSmoothInterval = 10000;
442+
uint64_t m_hashrateSmoothInterval = 10000;
443443
std::thread m_serviceThread; ///< The IO service thread.
444444
boost::asio::io_service m_io_service;
445445
boost::asio::deadline_timer m_hashrateTimer;

libhwmon/wrapadl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ int wrap_adl_get_power_usage(wrap_adl_handle *adlh, int gpuindex, unsigned int*
287287

288288
int power = 0;
289289
rc = adlh->adl2Overdrive6CurrentPowerGet(adlh->context, adlh->phys_logi_device_id[gpuindex], 0, &power);
290-
*miliwatts = power * 3.90625;
290+
*miliwatts = (unsigned int)(power * 3.90625);
291291
return rc;
292292
}
293293

libhwmon/wrapamdsysfs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ int wrap_amdsysfs_get_fanpcnt(wrap_amdsysfs_handle *sysfsh, int index, unsigned
312312
gpuindex, hwmonindex);
313313
getFileContentValue(dbuf, pwmMin);
314314

315-
*fanpcnt = double(pwm - pwmMin) / double(pwmMax - pwmMin) * 100.0;
315+
*fanpcnt = (unsigned int)(double(pwm - pwmMin) / double(pwmMax - pwmMin) * 100.0);
316316
return 0;
317317
}
318318

libpoolprotocols/stratum/EthStratumClient.cpp

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ static void diffToTarget(uint32_t *target, double diff)
3333

3434

3535
EthStratumClient::EthStratumClient(int const & worktimeout, string const & email, bool const & submitHashrate) : PoolClient(),
36-
m_socket(nullptr),
37-
m_securesocket(nullptr),
36+
m_socket(nullptr),
3837
m_worktimer(m_io_service),
3938
m_responsetimer(m_io_service),
4039
m_hashrate_event(m_io_service),
41-
m_resolver(m_io_service)
40+
m_resolver(m_io_service)
4241
{
4342
m_authorized = false;
4443
m_pending = 0;
@@ -54,15 +53,6 @@ EthStratumClient::~EthStratumClient()
5453
{
5554
m_io_service.stop();
5655
m_serviceThread.join();
57-
58-
if (m_connection.SecLevel() != SecureLevel::NONE) {
59-
if (m_securesocket)
60-
delete m_securesocket;
61-
}
62-
else {
63-
if (m_socket)
64-
delete m_socket;
65-
}
6656
}
6757

6858
void EthStratumClient::connect()
@@ -85,7 +75,7 @@ void EthStratumClient::connect()
8575
method = boost::asio::ssl::context::tlsv12;
8676

8777
boost::asio::ssl::context ctx(method);
88-
m_securesocket = new boost::asio::ssl::stream<boost::asio::ip::tcp::socket>(m_io_service, ctx);
78+
m_securesocket = std::make_shared<boost::asio::ssl::stream<boost::asio::ip::tcp::socket> >(m_io_service, ctx);
8979
m_socket = &m_securesocket->next_layer();
9080

9181
if (m_connection.SecLevel() != SecureLevel::ALLOW_SELFSIGNED) {
@@ -127,7 +117,8 @@ void EthStratumClient::connect()
127117
}
128118
}
129119
else {
130-
m_socket = new boost::asio::ip::tcp::socket(m_io_service);
120+
m_nonsecuresocket = std::make_shared<boost::asio::ip::tcp::socket>(m_io_service);
121+
m_socket = m_nonsecuresocket.get();
131122
}
132123

133124
// Activate keep alive to detect disconnects
@@ -182,14 +173,6 @@ void EthStratumClient::disconnect()
182173
catch (std::exception const& _e) {
183174
cwarn << "Error while disconnecting:" << _e.what();
184175
}
185-
186-
if (m_connection.SecLevel() != SecureLevel::NONE) {
187-
delete m_securesocket;
188-
}
189-
else {
190-
delete m_socket;
191-
}
192-
193176
m_authorized = false;
194177
m_connected.store(false, std::memory_order_relaxed);
195178

@@ -233,7 +216,7 @@ void EthStratumClient::async_write_with_response()
233216
boost::asio::placeholders::error));
234217
}
235218
else {
236-
async_write(*m_socket, m_requestBuffer,
219+
async_write(*m_nonsecuresocket, m_requestBuffer,
237220
boost::bind(&EthStratumClient::handleResponse, this,
238221
boost::asio::placeholders::error));
239222
}
@@ -606,7 +589,7 @@ void EthStratumClient::hashrate_event_handler(const boost::system::error_code& e
606589
async_write(*m_securesocket, m_requestBuffer,
607590
boost::bind(&EthStratumClient::handleHashrateResponse, this, boost::asio::placeholders::error));
608591
else
609-
async_write(*m_socket, m_requestBuffer,
592+
async_write(*m_nonsecuresocket, m_requestBuffer,
610593
boost::bind(&EthStratumClient::handleHashrateResponse, this, boost::asio::placeholders::error));
611594
}
612595

libpoolprotocols/stratum/EthStratumClient.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ class EthStratumClient : public PoolClient
7373
std::thread m_serviceThread; ///< The IO service thread.
7474
boost::asio::io_service m_io_service;
7575
boost::asio::ip::tcp::socket *m_socket;
76-
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> *m_securesocket;
76+
// Use shared ptrs to avoid crashes due to async_writes
77+
// see https://stackoverflow.com/questions/41526553/can-async-write-cause-segmentation-fault-when-this-is-deleted
78+
std::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket> >
79+
m_securesocket;
80+
std::shared_ptr<boost::asio::ip::tcp::socket>
81+
m_nonsecuresocket;
7782

7883
boost::asio::streambuf m_requestBuffer;
7984
boost::asio::streambuf m_responseBuffer;

0 commit comments

Comments
 (0)