HowardHinnant / date

A date and time library based on the C++11/14/17 <chrono> header
Other
3.08k stars 669 forks source link

AUTO_DOWNLOAD hangs in python module (windows) #763

Closed reder2000 closed 1 year ago

reder2000 commented 1 year ago

Using date in a python c++ module (pybind11), date hangs in init_tzdb while it is checking version against remote. curl hangs (more precisely: it is stuck in winnt waitforsingleobject) I tried to add a timeout but curl resume after timeout and hangs again.

Any idea / former experience ? (I use USE_SYSTEM_TZ_DB to resolve this, but it is not ideal). I tried digging around with no result. Not tried linux yet.

HowardHinnant commented 1 year ago

I have not heard of this symptom before.

One possibility to track this down is to try a pure C++ program on the same system and see if it hangs. Here is a possible test:

#include "date/tz.h"
#include <iostream>

int
main()
{
    std::cout << date::get_tzdb().version << '\n';
}

Built with this command line on macOS:

clang++ test.cpp -std=c++17 -I../date/include ../date/src/tz.cpp -lcurl

which for me just output:

2022g
reder2000 commented 1 year ago

Thanks for the advice, I have a full-featured library using date (thanks, so useful and much faster than msvc's version) and executable working perfectly (on windows msvc, mingw, and linux) with autoload. I've just started building a python interface for it as well and ran into problems (not a surprise given pybind11 has 421 issues and 119 PRs, but it looked lighter and more modern than boost.python that I used long time ago).

HowardHinnant commented 1 year ago

If I were to take a wild guess, it would be that one object file that involves a date source or header (tz.cpp, tz.h, date.h) is built with different configuration flags than another. With Make files that is all too easy to do.

reder2000 commented 1 year ago

Doubt it, it's a big cmakefile and I bring date by source. I'll try to find out something once I have time to test.

reder2000 commented 1 year ago

I have the same lockup in linux.

#0  0x00007ffff7d667ed in __GI___select (nfds=7, readfds=0x7fffffffb460, writefds=0x7fffffffb4e0, exceptfds=0x7fffffffb560, timeout=0x7fffffffb3d0)
    at ../sysdeps/unix/sysv/linux/select.c:69

[...]

#8  0x00007ffff6ac6d56 in date::download_to_string (url="https://www.iana.org/time-zones", str="")
    at /home/reder/vcpkg/buildtrees/date/src/v3.0.1-1676a5f906.clean/src/tz.cpp:2907

Closing as this is definitely pybind11 specific.

reder2000 commented 1 year ago

Note: I resolved this "issue" as managing to get static initialization at another place.