WaitTimeout() in wxSemaphore and wxCondition returns immediately instead of waiting for the timeout if system date > year 2038 (Issue #26466)

22 views
Skip to first unread message

danim7

unread,
May 15, 2026, 1:32:04 PM (4 days ago) May 15
to wx-...@googlegroups.com, Subscribed
danim7 created an issue (wxWidgets/wxWidgets#26466)

The WaitTimeout() function in wxSemaphore and wxCondition (and maybe others) returns immediately instead of waiting for the timeout if system date > 2038-01-19 03:14:07 UTC (aka.: https://en.wikipedia.org/wiki/Year_2038_problem)

I tested wxWidgets 3.2.10 on a VM running Debian 13.4.
To reproduce it, you can compile the following code:

#include <iostream>
#include <iomanip>
#include <wx/event.h>

using namespace std;

int main() {
	wxSemaphore sem;
	while (1) {
		auto t = time(nullptr);
		cout << "now: " << put_time(gmtime(&t), "%c") << endl;
		if (wxSEMA_TIMEOUT == sem.WaitTimeout(1000))
			cout << "got wxSEMA_TIMEOUT" << endl;
	}
}

Then, set the system date a few seconds before that time and launch the reproducer.
You may want to do the test inside a VM since you are messing with system date!

sudo timedatectl set-ntp false
sudo timedatectl set-timezone UTC
sudo timedatectl set-time "2038-01-19 03:14:00"
./reproducer

The loop will print one line per second until the SINT32_MAX limit, and then it will print many lines per second because it will no longer wait for the 1000 milliseconds timeout.

now: Tue Jan 19 03:14:00 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:01 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:02 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:03 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:04 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:05 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:06 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
now: Tue Jan 19 03:14:07 2038
got wxSEMA_TIMEOUT
^Ctrl-C

Let me know if I can help with any other information. I'm reporting it now because a migration to a new wxWidgets version might take quite years in downstream applications. Related: amule-project/amule#602


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26466@github.com>

VZ

unread,
May 15, 2026, 1:44:38 PM (4 days ago) May 15
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26466)

Thanks, reproduced (with master) simply by using faketime.

I'll have a look if nobody else does.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26466/4461961740@github.com>

VZ

unread,
May 15, 2026, 5:52:11 PM (3 days ago) May 15
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26466)

Fixed in #26469 which will be merged soon and backported to 3.2 a bit later, thanks again for reporting.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26466/4463979418@github.com>

danim7

unread,
May 16, 2026, 4:20:15 PM (2 days ago) May 16
to wx-...@googlegroups.com, Subscribed
danim7 left a comment (wxWidgets/wxWidgets#26466)

Just tested your branch and it is working now as expected. Thanks for your prompt action!


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26466/4467999970@github.com>

VZ

unread,
May 18, 2026, 10:43:38 PM (4 hours ago) May 18
to wx-...@googlegroups.com, Subscribed

Closed #26466 as completed via 24e72ef.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/26466/issue_event/25685983763@github.com>

Reply all
Reply to author
Forward
0 new messages