A suspected bug of CreateThread API usage #640

Open
opened 2026-01-30 21:57:47 +00:00 by claunia · 0 comments
Owner

Originally created by @MouriNaruto on GitHub (May 6, 2019).

First of all, I am very happy to read the source code of this project.

When I see the implementation of VtInputThread::Start() in /src/host/VtInputThread.cpp (35229a775d/src/host/VtInputThread.cpp (L160)) and found:

hThread = CreateThread(nullptr,
                           0,
                           (LPTHREAD_START_ROUTINE)VtInputThread::StaticVtInputThreadProc,
                           this,
                           0,
                           &dwThreadId);

RETURN_LAST_ERROR_IF(hThread == INVALID_HANDLE_VALUE);

And I also read the documentation of the CreateThread API (https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createthread) and found:

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

I am curious about that. Maybe this is a bug.

Kenji Mouri

Originally created by @MouriNaruto on GitHub (May 6, 2019). First of all, I am very happy to read the source code of this project. When I see the implementation of VtInputThread::Start() in /src/host/VtInputThread.cpp (https://github.com/Microsoft/Terminal/blob/35229a775d9e9908a8dfb102e01f49b494b29194/src/host/VtInputThread.cpp#L160) and found: ``` hThread = CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)VtInputThread::StaticVtInputThreadProc, this, 0, &dwThreadId); RETURN_LAST_ERROR_IF(hThread == INVALID_HANDLE_VALUE); ``` And I also read the documentation of the CreateThread API (https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createthread) and found: > If the function fails, **the return value is NULL**. To get extended error information, call GetLastError. I am curious about that. Maybe this is a bug. Kenji Mouri
claunia added the Help WantedProduct-ConhostIssue-BugNeeds-Tag-FixArea-Server labels 2026-01-30 21:57:47 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#640