Skip to content

并发断开连接时,接收线程在 wait_for 内崩溃(0xc0000005 访问冲突) #179

Description

@anyPaly

问题描述
我们在接收线程里遇到了硬崩溃(0xc0000005 访问冲突),位置在 wait_for 函数中循环条件处的 pred() 调用。触发场景是:接收端阻塞在 recv() 中等待消息,同时另一个线程对同一连接执行了 disconnect / destroy / clear。
运行环境
平台:Windows(x64)
编译器:MSVC(崩溃转储来自 Release 构建)

崩溃详情
ERROR_CODE(NTSTATUS) 0xc0000005
FAULTING_SOURCE_FILE: C:\Build\Project\cpp-ipc-cmake\src\libipc\ipc.cpp
FAULTING_SOURCE_LINE_NUMBER: 645

378: template <typename W, typename F>
379: bool wait_for(W& waiter, F&& pred, std::uint64_t tm) {
380: if (tm == 0) return !pred();

381: for (unsigned k = 0; pred();) {
382: bool ret = true;
383: ipc::sleep(k, [&k, &ret, &waiter, &pred, tm] {
384: ret = waiter.wait_if(std::forward(pred), tm);
385: k = 0;
386: });

请问可能会是什么问题

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions