GeniusVentures / SuperGenius

MIT License
4 stars 3 forks source link

Fix crash on DHT start + processing core #47

Open henriqueaklein opened 6 months ago

henriqueaklein commented 6 months ago

For some reason the processing core and DHT Start don't play well and ends up crashing on Linux This code crashes:

        pubsub_->GetDHT()->Start();

When this code is compiled:

processing_core_ = std::make_shared<processing::ProcessingCoreImpl>( globaldb_, 1000000, 2 );

Weirdly it doesn't need to run, the creation of the processing core can be called after the DHT Start and the side effect will occur before it ever runs and crashes on the boost library:

Image

The base_implementation_type contains null fields and that triggers a segfault (maybe because a socket '0' is valid). If we remove the processing core initialization, this code never runs on the DHT Start and it doesn't crash.

@itsafuu also did some investigating and got to AsynnIOManager's singletons as the possible trigger (but probably not the issue). By commenting a couple of singleton creations the error seems to disappear:


void FileManager::InitializeSingletons() {
    sgns::MNNLoader::InitializeSingleton();
    sgns::MNNParser::InitializeSingleton();
    //sgns::SFTPLoader::InitializeSingleton();
    sgns::HTTPLoader::InitializeSingleton();
    //sgns::WSLoader::InitializeSingleton();
    sgns::IPFSLoader::InitializeSingleton();
    sgns::IPFSSaver::InitializeSingleton();
    sgns::MNNSaver::InitializeSingleton();
}

This needs investigating because it might be memory invasion or concurrency issues