Skip to content

Conversation

@icing
Copy link
Contributor

@icing icing commented Oct 10, 2025

When thread creation fails, the code uses errno to remember the cause. But pthread_create() never sets errno and gives the error as return value. Fix that by setting the return value into errno on failure.

Windows: I think the ifdef was the wrong way around. Also set a generic Windows Error code on CE systems.

reported-by: Joshua Rogers

When thread creation fails, the code uses `errno` to remember the cause.
But pthread_create() never sets errno and gives the error as return value.
Fix that by setting the return value into errno on failure.

Windows: I think the ifdef was the wrong way around. Also set a generic
Windows Error code on CE systems.

reported-by: Joshua Rogers
@icing icing requested review from bagder and jay October 10, 2025 13:42
@bagder bagder closed this in 03448f4 Oct 10, 2025
@jay
Copy link
Member

jay commented Oct 10, 2025

Windows: I think the ifdef was the wrong way around. Also set a generic Windows Error code on CE systems.

I think you're right about that, and also Windows CE doesn't have a working errno AFAICS.

curl/lib/curl_setup.h

Lines 829 to 834 in 11b9912

#ifdef UNDER_CE
#define getenv curl_getenv /* Windows CE does not support getenv() */
#define raise(s) ((void)(s))
/* Terrible workarounds to make Windows CE compile */
#define errno 0
#define CURL_SETERRNO(x) ((void)(x))

/cc @vszakats

vszakats added a commit to vszakats/curl that referenced this pull request Oct 10, 2025
Both WinCE and Windows use CreateThread() now, so the use of
`GetLastError()` works for both.

Follow-up to 03448f4 curl#18998
Follow-up to 1c49f2f curl#18451
Follow-up to af02162 curl#1589
@vszakats
Copy link
Member

Nice catch, yes.

In #19015 I went along to delete the fallback branch. It became unnecessary
after moving both Windows and WinCE to CreateThread(), since GetLastError()
will provide the error code for both platforms after that.

vszakats added a commit to vszakats/curl that referenced this pull request Oct 10, 2025
Both WinCE and Windows use `CreateThread()` now, so the use of
`GetLastError()` works for both.

Follow-up to 03448f4 curl#18998
Follow-up to 1c49f2f curl#18451
Follow-up to af02162 curl#1589

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants