A suspected bug of CreateThread API usage #642

Closed
opened 2026-01-30 21:57:51 +00:00 by claunia · 2 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:51 +00:00
Author
Owner

@zadjii-msft commented on GitHub (May 6, 2019):

Oh, yea that might be a bug.

@zadjii-msft commented on GitHub (May 6, 2019): Oh, yea that might be a bug.
Author
Owner

@MouriNaruto commented on GitHub (May 6, 2019):

There are some implementations which have the same suspected bug.

PtySignalInputThread::Start() in src/host/PtySignalInputThread.cpp
35229a775d/src/host/PtySignalInputThread.cpp (L168)

@zadjii-msft

Kenji Mouri

@MouriNaruto commented on GitHub (May 6, 2019): There are some implementations which have the same suspected bug. PtySignalInputThread::Start() in src/host/PtySignalInputThread.cpp https://github.com/Microsoft/Terminal/blob/35229a775d9e9908a8dfb102e01f49b494b29194/src/host/PtySignalInputThread.cpp#L168 @zadjii-msft Kenji Mouri
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#642