microsoft / microsoft/Detours

Bug: Error process of GetQueuedCompletionStatus in syelogd.cpp.

Open
#264 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
6.4k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
When I use syslog to test my project, I found there is a bug in error process of GetQueuedCompletionStatus in syslogd.cpp (line 334).
The else branch will never be triggered.
And in this logic if client closed a piep, a work thread will exit.

       if (!b || lpo == NULL) {
            fKeepLooping = FALSE;
            MyErrExit("GetQueuedCompletionState");
            break;
        }
        else if (!b) {
            if (pClient) {
                if (GetLastError() == ERROR_BROKEN_PIPE) {
                    LogMessageV(SYELOG_SEVERITY_INFORMATION, "Client closed pipe.");
                }
                else {
                    LogMessageV(SYELOG_SEVERITY_ERROR,
                                "GetQueuedCompletionStatus failed %d [%p]",
                                GetLastError(), pClient);
                }
                CloseConnection(pClient);
            }
            continue;
        }

Expected behavior
I thought thread will exit only when both return value is false and lpo is NULL, as description in doc of GetQueuedCompletionStatus:

If a call to GetQueuedCompletionStatus fails because the completion port handle associated with it is closed while the call is outstanding, the function returns FALSE, *lpOverlapped will be NULL, and GetLastError will return ERROR_ABANDONED_WAIT_0.

I will create a PR for it.

Detours version

current master

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in syslogd.cpp at line 334 and read the GetQueuedCompletionStatus handling against the documented FALSE and lpOverlapped cases. Correct the error path so a client closing a pipe does not make a work thread exit, then verify that shutdown still handles the FALSE/NULL case and client errors are logged and closed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.