Skip to content

Commit 2da32cd

Browse files
committed
remove custom allocator for GMP. It has questionable utility and comes with heap corruption risks. Especially when init_gmp() is not called before everything else, and when asserting allow_integer_constructor is commented out
1 parent 87f6647 commit 2da32cd

10 files changed

+0
-71
lines changed

src/1weso_test.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ int main(int argc, char const* argv[]) try
2424
? std::stoull(argv[1]) : 1000000;
2525

2626
assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0
27-
init_gmp();
2827
debug_mode = true;
2928
if(hasAVX2())
3029
{

src/2weso_test.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ int main(int argc, char const* argv[]) try
3232
? std::stoull(argv[1]) : 1000000;
3333

3434
assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0
35-
init_gmp();
3635
debug_mode = true;
3736
if(hasAVX2())
3837
{

src/alloc.hpp

-58
This file was deleted.

src/avx512_test.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ template<class intnx, class avx512_intnx, class intjx, class avx512_intjx> void
7777

7878
int main(int argc, char **argv) {
7979
assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0
80-
init_gmp();
8180
set_rounding_mode();
8281

8382
enable_avx512_ifma=false;

src/hw/hw_test.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ static const char *discrs[] = {
3030
void init_chia(void)
3131
{
3232
VdfBaseInit();
33-
//init_gmp();
3433
//set_rounding_mode();
3534
//fesetround(FE_TOWARDZERO);
3635
}

src/integer_common.h

-5
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,14 @@ struct track_max_type {
111111
}
112112
};
113113
track_max_type track_max;
114-
//#define TRACK_MAX(data) track_max.add(#data " {" __func__ ":" "__LINE__" ")", (data).num_bits())
115114
#define TRACK_MAX(data) track_max.add(__LINE__, #data, (data).num_bits(), (data)<0)
116115

117-
//typedef __mpz_struct mpz_t[1];
118116
typedef __mpz_struct mpz_struct;
119117

120118
int mpz_num_bits_upper_bound(mpz_struct* v) {
121119
return mpz_size(v)*sizeof(mp_limb_t)*8;
122120
}
123121

124-
static bool allow_integer_constructor=false; //don't want static integers because they use the wrong allocator
125-
126122
//16 bytes
127123
struct integer {
128124
mpz_struct impl[1];
@@ -132,7 +128,6 @@ struct integer {
132128
}
133129

134130
inline integer() {
135-
//assert(allow_integer_constructor);
136131
mpz_init(impl);
137132
}
138133

src/prover_test.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ int gcd_128_max_iter=3;
3030

3131
int main() {
3232
assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0
33-
init_gmp();
3433
if(hasAVX2())
3534
{
3635
gcd_base_bits=63;

src/vdf_base.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
void VdfBaseInit(void)
88
{
9-
init_gmp();
109
fesetround(FE_TOWARDZERO);
1110
}
1211

src/vdf_bench.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ static void usage(const char *progname)
2626
int main(int argc, char **argv)
2727
{
2828
assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0
29-
init_gmp();
3029
set_rounding_mode();
3130

3231
if (argc < 3) {

src/vdf_client.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ int gcd_base_bits = 50;
311311
int gcd_128_max_iter = 3;
312312

313313
int main(int argc, char* argv[]) try {
314-
init_gmp();
315314
if (argc != 4) {
316315
std::cerr << "Usage: ./vdf_client <host> <port> <counter>\n";
317316
return 1;

0 commit comments

Comments
 (0)