thomasmoelhave / tpie

Templated Portable I/O Environment
Other
112 stars 24 forks source link

`file_stream::close()` does not terminate if TPIE has been Reinitialized #265

Open SSoelvsten opened 1 year ago

SSoelvsten commented 1 year ago

The following code is unexpectedly non-terminating.

#include <tpie/tpie.h>
#include <tpie/tempname.h>
#include <tpie/file_stream.h>

int main(int argc, char* argv[]) {
  tpie::tpie_init();
  tpie::get_memory_manager().set_limit(1024 * 1024 * 1024);
  tpie::tpie_finish();

  tpie::tpie_init();
  tpie::get_memory_manager().set_limit(1024 * 1024 * 1024);

  {
    tpie::temp_file f;
    tpie::file_stream<int> fs;
    fs.open(f);

    fs.write(42);

    fs.close(); // <-- does not terminate!
  }

  tpie::tpie_finish();
}

The problem lies in line 368 in stream_base.cpp is blocking when calling wait_for_request_done(l).