Undo all the work on determinism in the driver. New plan soon.

This commit is contained in:
2022-02-21 19:28:54 -05:00
parent ba1e923b5a
commit 19b6951e0f
14 changed files with 105 additions and 1146 deletions

View File

@@ -1,15 +1,3 @@
#define OPENSSL_HEAP_SIZE (4*1024*1024)
#define CHBUF_SIZE (256*1024)
#define POLLVEC_SIZE (DrivenEngine::MAX_CHAN+1)
int mallocstate(int n) {
int64_t result = 0;
for (int i = 0; i < n; i++) {
int64_t n = int64_t(malloc(1));
result = (result * 17) + n;
}
return result & 0x7fffffff;
}
static MonoClock monoclock;
@@ -19,6 +7,18 @@ namespace util {
}
}
static void initialize_engine() {
SourceDB::register_lua_builtins();
DrivenEngine::register_maker("textgame", make_TextGame);
DrivenEngine::register_maker("lpxclient", make_LpxClient);
DrivenEngine::register_maker("lpxserver", make_LpxServer);
DrivenEngine::register_maker("driverstubtest", make_DriverStubTest);
DrivenEngine::register_maker("driverwebservertest", make_DriverWebServerTest);
DrivenEngine::register_maker("driverdnsfailtest", make_DriverDNSFailTest);
DrivenEngine::register_maker("driverprintclocktest", make_DriverPrintClockTest);
DrivenEngine::register_maker("unittest", make_RunUnitTests);
}
static void if_error_print_and_exit(const UmmString &str) {
if (!str.empty()) {
std::cerr << std::endl << "error: " << str << std::endl;
@@ -70,8 +70,6 @@ static int ssl_ctx_use_privatekey_str(SSL_CTX *ctx, const char *str) {
return status;
}
static std::unique_ptr<char[]> chbuf;
static std::unique_ptr<struct pollfd[]> pollvec;
class Driver {
public:
@@ -503,23 +501,6 @@ public:
void driver_drive(int argc, char *argv[]) {
// The only place in the driver where we're allowed to use malloc
// is here, before even looking at the arguments. That way, the
// impact on the malloc heap is always exactly the same, which
// doesn't break the determinism of the execution during replay.
umm_init_heap(malloc(OPENSSL_HEAP_SIZE), OPENSSL_HEAP_SIZE);
CRYPTO_set_mem_functions(umm_malloc_ssl, umm_realloc_ssl, umm_free_ssl);
chbuf.reset(new char[CHBUF_SIZE]);
pollvec.reset(new struct pollfd[POLLVEC_SIZE]);
ERR_load_crypto_strings();
SSL_load_error_strings();
std::cerr << "#2 " << std::hex << mallocstate(1) << std::endl;
Driver driver;
if (argc < 2) {
DrivenEngine::print_usage(std::cerr, argv[0]);