asio icon indicating copy to clipboard operation
asio copied to clipboard

segfault when using BOOST_ASIO_DISABLE_THREADS or BOOST_ASIO_DISABLE_IOCP

Open kelbon opened this issue 5 months ago • 0 comments

Im using asio from boost 1.87 (on windows)

Everything worked, but I wanted to get performance from the fact that I use one thread

So i defined BOOST_ASIO_DISABLE_THREADS

target_compile_definitions(myexecutable PUBLIC BOOST_ASIO_DISABLE_THREADS=1)

And received segfault on first work here:

long timer_queue_set::wait_duration_usec(long max_duration) const
{
  long min_duration = max_duration;
  for (timer_queue_base* p = first_; p; p = p->next_)
    min_duration = p->wait_duration_usec(min_duration); <- Exception thrown at 0x00007F<...> in myexecutable.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
  return min_duration;
}

I thought it was related to the implicit threads that are created on Windows for timers. So I defined BOOST_ASIO_DISABLE_IOCP:

if (WIN32)
    target_compile_definitions(myexecutable PUBLIC BOOST_ASIO_DISABLE_IOCP=1)
endif()

After that my io_context.run() does nothing (literaly endless loop without work)

Next, i disabled BOOST_ASIO_DISABLE_THREADS again and defined ONLY BOOST_ASIO_DISABLE_IOCP

And... segfault:

  void lock()
  {
    ::EnterCriticalSection(&crit_section_); <- Exception thrown at 0x00007FFF<...> (ntdll.dll) in myexecutable.exe: 0xC0000005: Access violation writing location 0x0000000000000025.
  }

is it really that hard to just give a define to disable the mutex?

kelbon avatar Jul 20 '25 06:07 kelbon