Skip to content

On windows AsyncSubscriber causes exception in libuv upon destruction #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
borisu opened this issue Jun 23, 2024 · 6 comments
Open

Comments

@borisu
Copy link

borisu commented Jun 23, 2024

Not sure it bug or not but I am experiencing mentioned exception when destroying the object.

I am using redis++ via vcpkg for the https://github.com/borisu/bricks

In general, code template looks like that

auto redis = new AsyncRedis("....");
auto subscriber = new AsyncSubscriber(redis->subscriber());

/* do things */

try {
	auto f = subscriber->unsubscribe();
	f.wait();
}
catch (std::exception&) {};
delete subscriber;
delete redis

what happens is crash like that :-
Assertion failed: 0, file \vcpkg\buildtrees\libuv\src\v1.46.0-608af35d5c.clean\src\win\handle.c, line 71

Environment:

  • OS: Windows
  • Compiler: MSVC
  • hiredis version: latest of vcpkg
  • redis-plus-plus version: latest of vcpkg

Additional context
Add any other context about the problem here.

@borisu borisu changed the title On windows AsyncSubscriber causes exception in libuv On windows AsyncSubscriber causes exception in libuv upon destruction Jun 23, 2024
@yakovale-flutterint
Copy link

yakovale-flutterint commented Apr 17, 2025

have the same issue here, happens only with async interface when subscriber is obtained. Minimal example would be as follow:
`

{        

    AsyncRedis redis("redis://127.0.0.1:6379");
    AsyncSubscriber subscriber = redis.subscriber();
    std::this_thread::sleep_for(std::chrono::seconds(1));
}

`
getting an asssert on uv_close call when EventLoop destructor is called from ~AsyncRedis(). 1 sec sleep is kind of a business logic replacement.
Visual studio 2022, Redis cluster with 1 node only.
@sewenew could give an advise please?
Thanks

@sewenew
Copy link
Owner

sewenew commented Apr 18, 2025

Sorry, but I don't have a Windows box near to reproduce your problem. However, recently, I fixed a bug, which might be related.

Could you please update your code to the latest version and retry if the problem still exists? Thanks!

Regards

@yakovale-flutterint
Copy link

i tried with latest master, the code above with AsyncRedis works fine now, no assert, but if i substitute with AsyncRedisCluster it fails again. Maybe something was added to AsyncRedis but not to AsyncRedisCluster?

Code i've tried:
`
AsyncRedisCluster redis("redis://127.0.0.1:6379");
AsyncSubscriber subscriber = redis.subscriber();
std::this_thread::sleep_for(std::chrono::seconds(1));

`

trace the same as before, but now with Cluster destructor.
`

redisclient.exe!issue_debug_notification(const wchar_t * const message) Line 28 (AppData\Local\Programs\Microsoft VS Code\minkernel\crts\ucrt\src\appcrt\internal\report_runtime_error.cpp:28)
redisclient.exe!__acrt_report_runtime_error(const wchar_t * message) Line 154 (AppData\Local\Programs\Microsoft VS Code\minkernel\crts\ucrt\src\appcrt\internal\report_runtime_error.cpp:154)
redisclient.exe!abort() Line 61 (AppData\Local\Programs\Microsoft VS Code\minkernel\crts\ucrt\src\appcrt\startup\abort.cpp:61)
redisclient.exe!common_assert_to_stderr<wchar_t>(const wchar_t * const expression, const wchar_t * const file_name, const unsigned int line_number) Line 187 (AppData\Local\Programs\Microsoft VS Code\minkernel\crts\ucrt\src\appcrt\startup\assert.cpp:187)
redisclient.exe!common_assert<wchar_t>(const wchar_t * const expression, const wchar_t * const file_name, const unsigned int line_number, void * const return_address) Line 420 (AppData\Local\Programs\Microsoft VS Code\minkernel\crts\ucrt\src\appcrt\startup\assert.cpp:420)
redisclient.exe!_wassert(const wchar_t * expression, const wchar_t * file_name, unsigned int line_number) Line 444 (AppData\Local\Programs\Microsoft VS Code\minkernel\crts\ucrt\src\appcrt\startup\assert.cpp:444)
redisclient.exe!uv_close(uv_handle_s * handle, void(*)(uv_handle_s *) cb) Line 71 (.conan2\p\b\libuv2270c0f466786\b\src\src\win\handle.c:71)
redisclient.exe!sw::redis::EventLoop::LoopDeleter::()::__l2::(uv_handle_s * handle, void * __formal) Line 222 (.conan2\p\b\redis596c115ea3663\b\src\src\sw\redis++\event_loop.cpp:222)
redisclient.exe!void (uv_handle_s *, void )::<lambda_invoker_cdecl>(uv_handle_s * handle, void * __p2) Line 224 (.conan2\p\b\redis596c115ea3663\b\src\src\sw\redis++\event_loop.cpp:224)
redisclient.exe!uv_walk(uv_loop_s * loop, void(
)(uv_handle_s *, void *) walk_cb, void * arg) Line 549 (.conan2\p\b\libuv2270c0f466786\b\src\src\uv-common.c:549)
redisclient.exe!sw::redis::EventLoop::LoopDeleter::operator()(uv_loop_s * loop) Line 217 (.conan2\p\b\redis596c115ea3663\b\src\src\sw\redis++\event_loop.cpp:217)
redisclient.exe!std::unique_ptr<uv_loop_s,sw::redis::EventLoop::LoopDeleter>::~unique_ptr<uv_loop_s,sw::redis::EventLoop::LoopDeleter>() Line 3409 (c:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\memory:3409)
redisclient.exe!sw::redis::EventLoop::~EventLoop() Line 37 (.conan2\p\b\redis596c115ea3663\b\src\src\sw\redis++\event_loop.cpp:37)
redisclient.exe!sw::redis::EventLoop::`scalar deleting destructor'(unsigned int) (Unknown Source:0)
redisclient.exe!std::_Destroy_in_placesw::redis::EventLoop(sw::redis::EventLoop & _Obj) Line 324 (c:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\xmemory:324)
redisclient.exe!std::_Ref_count_obj2sw::redis::EventLoop::_Destroy() Line 2110 (c:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\memory:2110)
redisclient.exe!std::_Ref_count_base::_Decref() Line 1161 (c:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\memory:1161)
redisclient.exe!std::_Ptr_basesw::redis::EventLoop::_Decref() Line 1377 (c:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\memory:1377)
redisclient.exe!std::shared_ptrsw::redis::EventLoop::~shared_ptrsw::redis::EventLoop() Line 1682 (c:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\memory:1682)
redisclient.exe!sw::redis::AsyncRedisCluster::~AsyncRedisCluster() Line 56 (.conan2\p\b\redis596c115ea3663\p\include\sw\redis++\async_redis_cluster.h:56)

`

@sewenew
Copy link
Owner

sewenew commented Apr 26, 2025

@yakovale-flutterint Sorry, but I cannot reproduce your problem with the code you given on macOS. Did you do some other operations, e.g. shutdown Redis Cluster node? Also, it seems your example connected to a standalone Redis server (port: 6379), not a Redis Cluster.

Regards

@yakovale-flutterint
Copy link

yes, i delete objects and do it multiple times to have it reproduced. My server is a cluster, just start connecting to a specific node.


  #include <chrono>
  #include <sw/redis++/async_redis++.h>
  using namespace sw::redis;
  
  int main(int argc, char **argv) {
      for(int i = 0; i < 50; ++i)
      {
          {        
  
              AsyncRedisCluster redis("redis://127.0.0.1:6379");
              AsyncSubscriber subscriber = redis.subscriber();
              std::this_thread::sleep_for(std::chrono::seconds(1));
          }
      }
      return 1;
  }

Thanks

@sewenew
Copy link
Owner

sewenew commented May 11, 2025

Sorry, but I did lots of tests with your code snippets. However still cannot reproduce the problem.

I'll leave this issue open to see if I can reproduce the problem in the future, or someone else report the same issue.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants