Skip to content

Commit

Permalink
remove custom allocator for GMP. It has questionable utility and come…
Browse files Browse the repository at this point in the history
…s with heap corruption risks. Especially when init_gmp() is not called before everything else, and when asserting allow_integer_constructor is commented out
  • Loading branch information
arvidn committed Feb 4, 2025
1 parent 87f6647 commit 269c36f
Show file tree
Hide file tree
Showing 13 changed files with 0 additions and 76 deletions.
1 change: 0 additions & 1 deletion src/1weso_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ int main(int argc, char const* argv[]) try
? std::stoull(argv[1]) : 1000000;

assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0
init_gmp();
debug_mode = true;
if(hasAVX2())
{
Expand Down
1 change: 0 additions & 1 deletion src/2weso_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ int main(int argc, char const* argv[]) try
? std::stoull(argv[1]) : 1000000;

assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0
init_gmp();
debug_mode = true;
if(hasAVX2())
{
Expand Down
58 changes: 0 additions & 58 deletions src/alloc.hpp

This file was deleted.

1 change: 0 additions & 1 deletion src/avx512_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ template<class intnx, class avx512_intnx, class intjx, class avx512_intjx> void

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

enable_avx512_ifma=false;
Expand Down
1 change: 0 additions & 1 deletion src/hw/emu_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

//#include "verifier.h"
//#include "bit_manipulation.h"
//#include "alloc.hpp"
//#include "double_utility.h"

#include <inttypes.h>
Expand Down
2 changes: 0 additions & 2 deletions src/hw/hw_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//#include <cstdint>
//#include <cstring>
//#include <gmp.h>
//#include "alloc.hpp"
//#include "create_discriminant.h"

//#include "libft4222.h"
Expand All @@ -30,7 +29,6 @@ static const char *discrs[] = {
void init_chia(void)
{
VdfBaseInit();
//init_gmp();
//set_rounding_mode();
//fesetround(FE_TOWARDZERO);
}
Expand Down
5 changes: 0 additions & 5 deletions src/integer_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,14 @@ struct track_max_type {
}
};
track_max_type track_max;
//#define TRACK_MAX(data) track_max.add(#data " {" __func__ ":" "__LINE__" ")", (data).num_bits())
#define TRACK_MAX(data) track_max.add(__LINE__, #data, (data).num_bits(), (data)<0)

//typedef __mpz_struct mpz_t[1];
typedef __mpz_struct mpz_struct;

int mpz_num_bits_upper_bound(mpz_struct* v) {
return mpz_size(v)*sizeof(mp_limb_t)*8;
}

static bool allow_integer_constructor=false; //don't want static integers because they use the wrong allocator

//16 bytes
struct integer {
mpz_struct impl[1];
Expand All @@ -132,7 +128,6 @@ struct integer {
}

inline integer() {
//assert(allow_integer_constructor);
mpz_init(impl);
}

Expand Down
1 change: 0 additions & 1 deletion src/prover_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ int gcd_128_max_iter=3;

int main() {
assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0
init_gmp();
if(hasAVX2())
{
gcd_base_bits=63;
Expand Down
1 change: 0 additions & 1 deletion src/python_bindings/fastvdf.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <pybind11/pybind11.h>
#include "../verifier.h"
#include "../prover_slow.h"
#include "../alloc.hpp"

namespace py = pybind11;

Expand Down
1 change: 0 additions & 1 deletion src/threading.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef THREADING_H
#define THREADING_H

#include "alloc.hpp"
#include <atomic>

//mp_limb_t is an unsigned integer
Expand Down
2 changes: 0 additions & 2 deletions src/vdf_base.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#include "verifier.h"
#include "prover_slow.h"
#include "alloc.hpp"
#include "prover_base.hpp"
#include "prover_parallel.hpp"

void VdfBaseInit(void)
{
init_gmp();
fesetround(FE_TOWARDZERO);
}

Expand Down
1 change: 0 additions & 1 deletion src/vdf_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ static void usage(const char *progname)
int main(int argc, char **argv)
{
assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0
init_gmp();
set_rounding_mode();

if (argc < 3) {
Expand Down
1 change: 0 additions & 1 deletion src/vdf_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ int gcd_base_bits = 50;
int gcd_128_max_iter = 3;

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

0 comments on commit 269c36f

Please # to comment.