Skip to content

Commit 269c36f

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 269c36f

13 files changed

+0
-76
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/emu_funcs.cpp

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

44
//#include "verifier.h"
55
//#include "bit_manipulation.h"
6-
//#include "alloc.hpp"
76
//#include "double_utility.h"
87

98
#include <inttypes.h>

src/hw/hw_test.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//#include <cstdint>
66
//#include <cstring>
77
//#include <gmp.h>
8-
//#include "alloc.hpp"
98
//#include "create_discriminant.h"
109

1110
//#include "libft4222.h"
@@ -30,7 +29,6 @@ static const char *discrs[] = {
3029
void init_chia(void)
3130
{
3231
VdfBaseInit();
33-
//init_gmp();
3432
//set_rounding_mode();
3533
//fesetround(FE_TOWARDZERO);
3634
}

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/python_bindings/fastvdf.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <pybind11/pybind11.h>
22
#include "../verifier.h"
33
#include "../prover_slow.h"
4-
#include "../alloc.hpp"
54

65
namespace py = pybind11;
76

src/threading.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef THREADING_H
22
#define THREADING_H
33

4-
#include "alloc.hpp"
54
#include <atomic>
65

76
//mp_limb_t is an unsigned integer

src/vdf_base.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#include "verifier.h"
22
#include "prover_slow.h"
3-
#include "alloc.hpp"
43
#include "prover_base.hpp"
54
#include "prover_parallel.hpp"
65

76
void VdfBaseInit(void)
87
{
9-
init_gmp();
108
fesetround(FE_TOWARDZERO);
119
}
1210

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)