Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] BUG: Reading ORC segfaults on windows (if TZDIR isn't set) #36026

Closed
Tracked by #944
h-vetinari opened this issue Jun 11, 2023 · 56 comments
Closed
Tracked by #944

[Python] BUG: Reading ORC segfaults on windows (if TZDIR isn't set) #36026

h-vetinari opened this issue Jun 11, 2023 · 56 comments
Assignees
Labels
Component: Format Component: Packaging Component: Python Critical Fix Bugfixes for security vulnerabilities, crashes, or invalid data. Type: bug
Milestone

Comments

@h-vetinari
Copy link
Contributor

h-vetinari commented Jun 11, 2023

Describe the bug, including details regarding any error messages, version, and platform.

orc on windows doesn't exist for a long time yet in conda-forge, and we've only recently enabled it for the C++ portion of arrow. I tried to switch it on for pyarrow now as well in conda-forge/arrow-cpp-feedstock#1086, and the test suite segfaults as soon as it gets to test_dataset.py::test_orc_format

stacktrace
[...]
test_dataset.py::test_ipc_format[threaded] PASSED                        [ 20%]
test_dataset.py::test_ipc_format[serial] PASSED                          [ 20%]
Fatal Python error: Aborted

Thread 0x00000ea0 (most recent call first):
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pyarrow\tests\test_dataset.py", line 261 in to_table
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pyarrow\tests\test_dataset.py", line 2991 in test_orc_format
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\python.py", line 194 in pytest_pyfunc_call
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_callers.py", line 39 in _multicall
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_manager.py", line 80 in _hookexec
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_hooks.py", line 265 in __call__
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\python.py", line 1799 in runtest
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\runner.py", line 169 in pytest_runtest_call
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_callers.py", line 39 in _multicall
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_manager.py", line 80 in _hookexec
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_hooks.py", line 265 in __call__
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\runner.py", line 262 in <lambda>
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\runner.py", line 341 in from_call
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\runner.py", line 261 in call_runtest_hook
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\runner.py", line 222 in call_and_report
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\runner.py", line 133 in runtestprotocol
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\runner.py", line 114 in pytest_runtest_protocol
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_callers.py", line 39 in _multicall
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_manager.py", line 80 in _hookexec
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_hooks.py", line 265 in __call__
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\main.py", line 348 in pytest_runtestloop
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_callers.py", line 39 in _multicall
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_manager.py", line 80 in _hookexec
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_hooks.py", line 265 in __call__
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\main.py", line 323 in _main
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\main.py", line 269 in wrap_session
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\main.py", line 316 in pytest_cmdline_main
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_callers.py", line 39 in _multicall
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_manager.py", line 80 in _hookexec
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\pluggy\_hooks.py", line 265 in __call__
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\config\__init__.py", line 166 in main
  File "D:\bld\apache-arrow_1686428319811\_test_env\Lib\site-packages\_pytest\config\__init__.py", line 189 in console_main
  File "D:\bld\apache-arrow_1686428319811\_test_env\Scripts\pytest-script.py", line 9 in <module>

Extension modules: numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, pyarrow.lib, pyarrow._hdfsio, pyarrow._fs, pyarrow._hdfs, pyarrow._gcsfs, pyarrow._s3fs, pandas._libs.tslibs.np_datetime, pandas._libs.tslibs.dtypes, pandas._libs.tslibs.base, pandas._libs.tslibs.nattype, pandas._libs.tslibs.timezones, pandas._libs.tslibs.ccalendar, pandas._libs.tslibs.fields, pandas._libs.tslibs.timedeltas, pandas._libs.tslibs.tzconversion, pandas._libs.tslibs.timestamps, pandas._libs.properties, pandas._libs.tslibs.offsets, pandas._libs.tslibs.strptime, pandas._libs.tslibs.parsing, pandas._libs.tslibs.conversion, pandas._libs.tslibs.period, pandas._libs.tslibs.vectorized, pandas._libs.ops_dispatch, pandas._libs.missing, pandas._libs.hashtable, pandas._libs.algos, pandas._libs.interval, pandas._libs.lib, pandas._libs.hashing, pandas._libs.tslib, pandas._libs.ops, pyarrow._compute, pandas._libs.arrays, pandas._libs.sparse, pandas._libs.reduction, pandas._libs.indexing, pandas._libs.index, pandas._libs.internals, pandas._libs.join, pandas._libs.writers, pandas._libs.window.aggregations, pandas._libs.window.indexers, pandas._libs.reshape, pandas._libs.groupby, pandas._libs.testing, pandas._libs.parsers, pandas._libs.json, fastparquet.cencoding, fastparquet.speedups, pyarrow.gandiva, pyarrow._acero, pyarrow._csv, pyarrow._dataset, pyarrow._dataset_orc, pyarrow._parquet, pyarrow._dataset_parquet, pyarrow._orc, pyarrow._parquet_encryption, pyarrow._flight, pyarrow._substrait, _cffi_backend, pyarrow._pyarrow_cpp_tests, pyarrow._feather, pyarrow._json, numpy.linalg.lapack_lite, scipy._lib._ccallback_c, scipy.sparse._sparsetools, scipy.sparse._csparsetools, scipy.sparse.linalg._isolve._iterative, scipy.linalg._fblas, scipy.linalg._flapack, scipy.linalg._cythonized_array_utils, scipy.linalg._flinalg, scipy.linalg._solve_toeplitz, scipy.linalg._matfuncs_sqrtm_triu, scipy.linalg.cython_lapack, scipy.linalg.cython_blas, scipy.linalg._matfuncs_expm, scipy.linalg._decomp_update, scipy.sparse.linalg._dsolve._superlu, scipy.sparse.linalg._eigen.arpack._arpack, scipy.sparse.csgraph._tools, scipy.sparse.csgraph._shortest_path, scipy.sparse.csgraph._traversal, scipy.sparse.csgraph._min_spanning_tree, scipy.sparse.csgraph._flow, scipy.sparse.csgraph._matching, scipy.sparse.csgraph._reordering, pyarrow_cython_example, bound_function_visit_strings (total: 104)
Tests failed for pyarrow-tests-12.0.0-py311h385a57a_8_cpu.conda - moving package to D:\bld\broken
WARNING:conda_build.build:Tests failed for pyarrow-tests-12.0.0-py311h385a57a_8_cpu.conda - moving package to D:\bld\broken
TESTS FAILED: pyarrow-tests-12.0.0-py311h385a57a_8_cpu.conda

Component(s)

Format, Packaging, Python

@kou kou changed the title BUG: test_orc_format segfaults on windows [Python] BUG: test_orc_format segfaults on windows Jun 11, 2023
@h-vetinari
Copy link
Contributor Author

The same segfault still appears with orc 1.9

@mapleFU
Copy link
Member

mapleFU commented Jul 2, 2023

@wgtmac may this related to C++ Orc release?

@wgtmac
Copy link
Member

wgtmac commented Jul 2, 2023

@wgtmac may this related to C++ Orc release?

I don't think so. It seems that this issue exists in the old 1.8.x releases as well.

@h-vetinari
Copy link
Contributor Author

Definitely not related to 1.9; the segfault happened in the exact same place before for 1.8.3. I don't have data before that.

@wgtmac wgtmac self-assigned this Jul 8, 2023
@wgtmac
Copy link
Member

wgtmac commented Jul 8, 2023

I am not familiar with python or pyarrow. Does it mean I can simply run the failed test on Windows to reproduce this issue? @h-vetinari

@h-vetinari
Copy link
Contributor Author

Hey @wgtmac, thanks for taking a look! It's from a pretty "standard" build, though arrow & pyarrow are quite a handful, especially considering all the dependencies. I could publish the failing builds in a way that they're (opt-in) installable using conda/mamba/miniforge, would that help?

Otherwise, you could just try building arrow & pyarrow with -DARROW_ORC=ON and export PYARROW_WITH_ORC=1 on windows (and then run the python test suite), and see whether the problem is reproducible like that.

@wgtmac
Copy link
Member

wgtmac commented Jul 9, 2023

Thanks for the info! Let me spend some time to build it on Windows first.

@h-vetinari
Copy link
Contributor Author

Still segfaulting as of 13.0.0

@raulcd
Copy link
Member

raulcd commented Aug 24, 2023

It does seem that ORC is disabled on our Windows wheels:
https://github.com/apache/arrow/blob/main/ci/scripts/python_wheel_windows_build.bat#L39
Maybe this is not tested anywhere as I can't find any Windows Pyarrow test with ORC enabled because on Appveyor we use ARROW_ORC=ON https://github.com/apache/arrow/blob/main/ci/appveyor-cpp-build.bat#L80 but we don't enable it for PYARROW: https://github.com/apache/arrow/blob/main/ci/appveyor-cpp-build.bat#L117-L129

@raulcd
Copy link
Member

raulcd commented Aug 24, 2023

@kou @jorisvandenbossche do you know if we are testing ORC enabled on Windows for Pyarrow somewhere else?

@jorisvandenbossche
Copy link
Member

Do we have any other Windows testing at all?

I suppose not testing ORC for pyarrow on appveyor is just an oversight, since it needs to be enabled manually? (and we forgot to do that) So we could start with enabling it there, and see if we can reproduce those errors?

@kou
Copy link
Member

kou commented Aug 25, 2023

Oh, let's enable it.

@raulcd
Copy link
Member

raulcd commented Aug 25, 2023

I've enabled it for Appveyor and I was not able to reproduce the issue, see the successful build here: https://ci.appveyor.com/project/ApacheSoftwareFoundation/arrow/builds/47879511
I am trying to enable it on the Windows wheels too.

@raulcd
Copy link
Member

raulcd commented Aug 29, 2023

I haven't been able to reproduce this issue neither on the Windows wheels nor the Appveyor build.

@jorisvandenbossche jorisvandenbossche changed the title [Python] BUG: test_orc_format segfaults on windows [Python] BUG: test_orc_format segfaults on windows (conda-forge) Aug 29, 2023
@raulcd
Copy link
Member

raulcd commented Aug 29, 2023

Sorry, it seems I was missing the following to test orc on the Wheels job: ce4fe1c
I've been able to reproduce the failure on the wheels jobs on this PR, the failed jobs here:

stacktrace
Python311\Lib\site-packages\pyarrow\tests\test_dataset.py .............. [ 24%]
........................................................................ [ 24%]
Fatal Python error: Aborted
Thread 0x00001ab0 (most recent call first):
  File "C:\Python311\Lib\site-packages\pyarrow\tests\test_dataset.py", line 261 in to_table
  File "C:\Python311\Lib\site-packages\pyarrow\tests\test_dataset.py", line 3072 in test_orc_format
  File "C:\Python311\Lib\site-packages\_pytest\python.py", line 194 in pytest_pyfunc_call
  File "C:\Python311\Lib\site-packages\pluggy\_callers.py", line 77 in _multicall
  File "C:\Python311\Lib\site-packages\pluggy\_manager.py", line 115 in _hookexec
  File "C:\Python311\Lib\site-packages\pluggy\_hooks.py", line 493 in __call__
  File "C:\Python311\Lib\site-packages\_pytest\python.py", line 1788 in runtest
  File "C:\Python311\Lib\site-packages\_pytest\runner.py", line 169 in pytest_runtest_call
  File "C:\Python311\Lib\site-packages\pluggy\_callers.py", line 77 in _multicall
  File "C:\Python311\Lib\site-packages\pluggy\_manager.py", line 115 in _hookexec
  File "C:\Python311\Lib\site-packages\pluggy\_hooks.py", line 493 in __call__
  File "C:\Python311\Lib\site-packages\_pytest\runner.py", line 262 in <lambda>
  File "C:\Python311\Lib\site-packages\_pytest\runner.py", line 341 in from_call
  File "C:\Python311\Lib\site-packages\_pytest\runner.py", line 261 in call_runtest_hook
  File "C:\Python311\Lib\site-packages\_pytest\runner.py", line 222 in call_and_report
  File "C:\Python311\Lib\site-packages\_pytest\runner.py", line 133 in runtestprotocol
  File "C:\Python311\Lib\site-packages\_pytest\runner.py", line 114 in pytest_runtest_protocol
  File "C:\Python311\Lib\site-packages\pluggy\_callers.py", line 77 in _multicall
  File "C:\Python311\Lib\site-packages\pluggy\_manager.py", line 115 in _hookexec
  File "C:\Python311\Lib\site-packages\pluggy\_hooks.py", line 493 in __call__
  File "C:\Python311\Lib\site-packages\_pytest\main.py", line 349 in pytest_runtestloop
  File "C:\Python311\Lib\site-packages\pluggy\_callers.py", line 77 in _multicall
  File "C:\Python311\Lib\site-packages\pluggy\_manager.py", line 115 in _hookexec
  File "C:\Python311\Lib\site-packages\pluggy\_hooks.py", line 493 in __call__
  File "C:\Python311\Lib\site-packages\_pytest\main.py", line 324 in _main
  File "C:\Python311\Lib\site-packages\_pytest\main.py", line 270 in wrap_session
  File "C:\Python311\Lib\site-packages\_pytest\main.py", line 317 in pytest_cmdline_main
  File "C:\Python311\Lib\site-packages\pluggy\_callers.py", line 77 in _multicall
  File "C:\Python311\Lib\site-packages\pluggy\_manager.py", line 115 in _hookexec
  File "C:\Python311\Lib\site-packages\pluggy\_hooks.py", line 493 in __call__
  File "C:\Python311\Lib\site-packages\_pytest\config\__init__.py", line 166 in main
  File "C:\Python311\Lib\site-packages\_pytest\config\__init__.py", line 189 in console_main
  File "C:\Python311\Scripts\pytest.exe\__main__.py", line 7 in <module>
  File "<frozen runpy>", line 88 in _run_code
  File "<frozen runpy>", line 198 in _run_module_as_main
Extension modules: numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, pyarrow.lib, pyarrow._hdfsio, pyarrow._fs, pyarrow._hdfs, pyarrow._gcsfs, pyarrow._s3fs, cython.cimports.libc.math, pyarrow._compute, pyarrow._acero, pyarrow._csv, pyarrow._json, pandas._libs.tslibs.np_datetime, pandas._libs.tslibs.dtypes, pandas._libs.tslibs.base, pandas._libs.tslibs.nattype, pandas._libs.tslibs.timezones, pandas._libs.tslibs.ccalendar, pandas._libs.tslibs.fields, pandas._libs.tslibs.timedeltas, pandas._libs.tslibs.tzconversion, pandas._libs.tslibs.timestamps, pandas._libs.properties, pandas._libs.tslibs.offsets, pandas._libs.tslibs.strptime, pandas._libs.tslibs.parsing, pandas._libs.tslibs.conversion, pandas._libs.tslibs.period, pandas._libs.ts...

@raulcd raulcd changed the title [Python] BUG: test_orc_format segfaults on windows (conda-forge) [Python] BUG: test_orc_format segfaults on windows Aug 29, 2023
@h-vetinari
Copy link
Contributor Author

Segfault on windows remains as of v14

@h-vetinari
Copy link
Contributor Author

Still segfaulting as of v15

@h-vetinari
Copy link
Contributor Author

Still segfaulting also with orc 2.0.0 (arrow 15.0.1)

@wgtmac
Copy link
Member

wgtmac commented Mar 14, 2024

I tried to reproduce it on my Windows PC following the guide https://arrow.apache.org/docs/developers/python.html#building-on-windows

Following commands were executed successfully and arrow cpp library was installed.

"E:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat"

conda create -y -n pyarrow-dev -c conda-forge ^
      --file arrow\ci\conda_env_cpp.txt ^
      --file arrow\ci\conda_env_python.txt ^
      --file arrow\ci\conda_env_gandiva.txt ^
      python=3.12
conda activate pyarrow-dev

pushd arrow\cpp\build
set ARROW_HOME=%CONDA_PREFIX%\Library
cmake -G "Visual Studio 17 2022" -A x64 ^
      -DCMAKE_INSTALL_PREFIX=%ARROW_HOME% ^
      -DCMAKE_UNITY_BUILD=ON ^
      -DARROW_CXXFLAGS="/WX /MP" ^
      -DARROW_ORC=ON ^
      ..
cmake --build . --target install --config Release
popd

However, when I tried to build pyarrow as below,

pushd arrow\python
set CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1
set PYARROW_CMAKE_GENERATOR=Visual Studio 17 2022
set PYARROW_CXXFLAGS="-A x64"
set PYARROW_WITH_ORC=1
python setup.py build_ext --inplace
popd

it complained for missing LZ4:

-- Found Protobuf: C:/Users/wgtmac/.conda/envs/pyarrow-dev/Library/lib/libprotobuf.lib (found version "3.21.12")
-- Found ZLIB: C:/Users/wgtmac/.conda/envs/pyarrow-dev/Library/lib/z.lib (found version "1.2.13")
CMake Warning at C:/Users/wgtmac/.conda/envs/pyarrow-dev/Library/lib/cmake/Arrow/Findlz4Alt.cmake:29 (find_package):
  By not providing "Findlz4.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "lz4", but
  CMake did not find one.

  Could not find a package configuration file provided by "lz4" with any of
  the following names:

    lz4Config.cmake
    lz4-config.cmake

  Add the installation prefix of "lz4" to CMAKE_PREFIX_PATH or set "lz4_DIR"
  to a directory containing one of the above files.  If "lz4" provides a
  separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  C:/Users/wgtmac/.conda/envs/pyarrow-dev/Library/share/cmake-3.28/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  C:/Users/wgtmac/.conda/envs/pyarrow-dev/Library/lib/cmake/Arrow/ArrowConfig.cmake:99 (find_dependency)
  C:/Users/wgtmac/.conda/envs/pyarrow-dev/Library/lib/cmake/Arrow/ArrowConfig.cmake:122 (arrow_find_dependencies)
  CMakeLists.txt:271 (find_package)

-- Checking for module 'liblz4'
--   No package 'liblz4' found
CMake Error at C:/Users/wgtmac/.conda/envs/pyarrow-dev/Library/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find lz4Alt (missing: LZ4_LIB)
Call Stack (most recent call first):
  C:/Users/wgtmac/.conda/envs/pyarrow-dev/Library/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  C:/Users/wgtmac/.conda/envs/pyarrow-dev/Library/lib/cmake/Arrow/Findlz4Alt.cmake:97 (find_package_handle_standard_args)
  C:/Users/wgtmac/.conda/envs/pyarrow-dev/Library/share/cmake-3.28/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  C:/Users/wgtmac/.conda/envs/pyarrow-dev/Library/lib/cmake/Arrow/ArrowConfig.cmake:99 (find_dependency)
  C:/Users/wgtmac/.conda/envs/pyarrow-dev/Library/lib/cmake/Arrow/ArrowConfig.cmake:122 (arrow_find_dependencies)
  CMakeLists.txt:271 (find_package)

-- Configuring incomplete, errors occurred!

I can confirm that the file C:\Users\wgtmac\.conda\envs\pyarrow-dev\Library\lib\liblz4.lib exists. And I tried to explicitly disable ARROW_WITH_LZ4 but it seems to be turned on anyway.

Do you have any idea? @h-vetinari @raulcd

@jorisvandenbossche
Copy link
Member

Currently it is hardcoded (if the env variable is not set) to "/usr/share/zoneinfo" (https://github.com/apache/orc/blob/0b4631bc343ed559e284ea6f824f31890f798e31/c%2B%2B/src/Timezone.cc#L33-L34)

I am not super familiar about whether there are standard ways to get a "user" or "app" prefix (we use $PREFIX in our (conda) CI, but that's because we set that ourselves, not necessarily because that is a standard?).
For conda you can get this as $CONDA_PREFIX, but I don't know if you want to include conda specific code in the ORC library itself.

Another option would also be to allow to specify a path at run time (we do that in Arrow for the tz database that is used by the kernels with arrow::GlobalOptions:;timezone_db_path), and then in the (py)arrow code we could be more opinionated about which path to set.

@wgtmac
Copy link
Member

wgtmac commented Mar 20, 2024

Thanks for the suggestion!

allow to specify a path at run time

This sounds like a good alternative to me.

kou pushed a commit that referenced this issue Mar 20, 2024
…test (#40609)

### Rationale for this change

The pyarrow orc reader always crashes when it tries to create an internal orc reader. This is caused by failing to read tz database on the local host. This also disables windows wheel build when ARROW_ORC is turned on.

### What changes are included in this PR?

Download IANA timezone database on the test host and explicitly setting TZDIR to make the CIs happy.

### Are these changes tested?

Make sure all python wheel windows CIs pass.

### Are there any user-facing changes?

No.
* GitHub Issue: #36026

Authored-by: Gang Wu <ustcwg@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
@kou kou added this to the 16.0.0 milestone Mar 20, 2024
@kou
Copy link
Member

kou commented Mar 20, 2024

Issue resolved by pull request 40609
#40609

@kou kou closed this as completed Mar 20, 2024
@jorisvandenbossche
Copy link
Member

As I mentioned above (#36026 (comment)), the PR didn't really fix this issue, it just hides it in our own tests, but users still get a segfault.

For 16.0 (and until ORC fixes this), we could also add a check on our side? Eg, if on windows, check that the env variable is set / the path is available, and if not raise an informative error to the user instead of segfaulting.

@pitrou pitrou reopened this Mar 20, 2024
@pitrou
Copy link
Member

pitrou commented Mar 20, 2024

Right, can the crash be averted? If a C++ exception is raised, then it can be caught and turned into a proper error.

@wgtmac
Copy link
Member

wgtmac commented Mar 20, 2024

Right, can the crash be averted? If a C++ exception is raised, then it can be caught and turned into a proper error.

If we can upgrade to ORC 2.0.0, then it will throw if the file path does not exist: https://github.com/apache/orc/blob/main/c%2B%2B/src/Timezone.cc#L678-L682

However, it seems that the current version (1.9.2) simply crashes when open is called: https://github.com/apache/orc/blob/0b4631bc343ed559e284ea6f824f31890f798e31/c%2B%2B/src/OrcFile.cc#L58-L68

@pitrou
Copy link
Member

pitrou commented Mar 20, 2024

However, it seems that the current version (1.9.2) simply crashes when open is called: https://github.com/apache/orc/blob/0b4631bc343ed559e284ea6f824f31890f798e31/c%2B%2B/src/OrcFile.cc#L58-L68

Well, it throws a C++ exception (ParseError), right?

@jorisvandenbossche jorisvandenbossche changed the title [Python] BUG: test_orc_format segfaults on windows [Python] BUG: Reading ORC segfaults on windows (if TZDIR isn't set) Mar 20, 2024
@wgtmac
Copy link
Member

wgtmac commented Mar 20, 2024

I need to debug it on Windows. If open() returns -1 and throws the exception, then we should already catch it and see the error message.

wgtmac added a commit to wgtmac/arrow that referenced this issue Mar 21, 2024
dongjoon-hyun pushed a commit to apache/orc that referenced this issue Mar 22, 2024
### What changes were proposed in this pull request?

Enable TestTimezone.testMissingTZDB unit test to run on Windows.

### Why are the changes needed?

When /usr/share/zoneinfo is unavailable and TZDIR env is unset, creating C++ ORC reader will crash on Windows. We need to better deal with this case. See context from the Apache Arrow community: apache/arrow#36026 and apache/arrow#40633

### How was this patch tested?

Make sure the test passes on Windows.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #1856 from wgtmac/win_tz_test.

Authored-by: Gang Wu <ustcwg@gmail.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
dongjoon-hyun pushed a commit to apache/orc that referenced this issue Mar 22, 2024
### What changes were proposed in this pull request?

Enable TestTimezone.testMissingTZDB unit test to run on Windows.

### Why are the changes needed?

When /usr/share/zoneinfo is unavailable and TZDIR env is unset, creating C++ ORC reader will crash on Windows. We need to better deal with this case. See context from the Apache Arrow community: apache/arrow#36026 and apache/arrow#40633

### How was this patch tested?

Make sure the test passes on Windows.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #1856 from wgtmac/win_tz_test.

Authored-by: Gang Wu <ustcwg@gmail.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
pitrou pushed a commit that referenced this issue Mar 26, 2024
### Rationale for this change

When /usr/share/zoneinfo is unavailable and TZDIR env is unset, creating C++ ORC reader will crash on Windows. We need to eagerly check this and prevent followup crash.

### What changes are included in this PR?

Eagerly check TZDB availability before creating ORC reader/writer.

### Are these changes tested?

Yes, added a test case to make sure the check work as expected.

### Are there any user-facing changes?

Users on Windows (or other cases when TZDB is not availble) will clearly see this error message instead of crash.
* GitHub Issue: #36026

Authored-by: Gang Wu <ustcwg@gmail.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
@pitrou
Copy link
Member

pitrou commented Mar 26, 2024

Issue resolved by pull request 40697
#40697

@h-vetinari
Copy link
Contributor Author

Like I said, the right approach IMO is to search a couple of reasonable candidate paths for the TZDB, including $PREFIX/share/zoneinfo (also on windows).

I tried to do this, but with recent changes that guard the check on ARROW_ORC_NEED_TIME_ZONE_DATABASE_CHECK (only for orc <2), this cannot really be done in arrow. So I've opened a PR to orc instead: apache/orc#1882

wgtmac pushed a commit to apache/orc that referenced this issue Apr 12, 2024
### What changes were proposed in this pull request?

Find tzdb without having to set `TZDIR` when in a conda-environment (where `tzdata` [has](https://conda-metadata-app.streamlit.app/?q=conda-forge%2Fnoarch%2Ftzdata-2024a-h0c530f3_0.conda) a uniform location of `$CONDA_PREFIX/share/zoneinfo` across all platforms).

### Why are the changes needed?

This is due to issues in arrow (see apache/arrow#36026) that cannot really be fixed there, as it assumes that orc >=2.0 knows how to find the tzdb. Having to set `TZDIR` in all user environments is an intrusive change that should be avoided, and since the cost here is checking a single environment variable, it's hopefully not too onerous for consideration.

### How was this patch tested?

CI here

### Was this patch authored or co-authored using generative AI tooling?

No

CC wgtmac

See also: #1587

Closes #1882 from h-vetinari/tzdb.

Authored-by: H. Vetinari <h.vetinari@gmx.com>
Signed-off-by: Gang Wu <ustcwg@gmail.com>
wgtmac pushed a commit to apache/orc that referenced this issue Apr 12, 2024
### What changes were proposed in this pull request?

Find tzdb without having to set `TZDIR` when in a conda-environment (where `tzdata` [has](https://conda-metadata-app.streamlit.app/?q=conda-forge%2Fnoarch%2Ftzdata-2024a-h0c530f3_0.conda) a uniform location of `$CONDA_PREFIX/share/zoneinfo` across all platforms).

### Why are the changes needed?

This is due to issues in arrow (see apache/arrow#36026) that cannot really be fixed there, as it assumes that orc >=2.0 knows how to find the tzdb. Having to set `TZDIR` in all user environments is an intrusive change that should be avoided, and since the cost here is checking a single environment variable, it's hopefully not too onerous for consideration.

### How was this patch tested?

CI here

### Was this patch authored or co-authored using generative AI tooling?

No

CC wgtmac

See also: #1587

Closes #1882 from h-vetinari/tzdb.

Authored-by: H. Vetinari <h.vetinari@gmx.com>
Signed-off-by: Gang Wu <ustcwg@gmail.com>
(cherry picked from commit e89ca33)
Signed-off-by: Gang Wu <ustcwg@gmail.com>
@h-vetinari
Copy link
Contributor Author

JFYI: apache/orc#1882 was merged (thanks @wgtmac!), so we'll be able to fix this in conda-forge without injecting TZDIR environment variables into every user environment.

@amoeba amoeba added the Critical Fix Bugfixes for security vulnerabilities, crashes, or invalid data. label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Format Component: Packaging Component: Python Critical Fix Bugfixes for security vulnerabilities, crashes, or invalid data. Type: bug
Projects
None yet
Development

No branches or pull requests

8 participants