pytorch - ✅(Solved) Fix [Build] UnicodeDecodeError in cmake_utils.py due to non-standard library version suffixes (e.g., OpenSSL 1.1.1wa) [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#182760Fetched 2026-05-07 03:30:23
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

PR fix notes

PR #182612: Ignore decoding errors when reading CMake cache files (errors='ignore')

Description (problem / solution / changelog)

When reading CMakeCache.txt, invalid byte sequences may appear,which cause build error:

File "tools/setup_helpers/env.py", line 68, in __init__
      cmake_cache_vars = get_cmake_cache_variables_from_file(f)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "tools/setup_helpers/cmake_utils.py", line 57, in get_cmake_cache_variables_from_file
      for i, line in enumerate(cmake_cache_file, 1):
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "<frozen codecs>", line 322, in decode
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 6452: invalid continuation byte
  error: subprocess-exited-with-error

This PR adds errors='ignore' to the open calls, invalid characters will be silently skipped, allowing the CMake cache variables to be read successfully.

Changed files

  • tools/setup_helpers/cmake.py (modified, +1/-1)
  • tools/setup_helpers/env.py (modified, +1/-1)

Code Example

ls -l /usr/lib64/libcrypto.so
lrwxrwxrwx. 1 root root 20 Oct 14 2025 /usr/lib64/libcrypto.so -> libcrypto.so.1.1.1wa
RAW_BUFFERClick to expand / collapse

The PyTorch build process (specifically the CMake cache parser) crashes with a UnicodeDecodeError when the system libraries have non-standard version suffixes that CMake captures as non-UTF-8 sequences.

In tools/setup_helpers/cmake_utils.py, the function get_cmake_cache_variables_from_file reads CMakeCache.txt using the default UTF-8 encoding. However, CMake often captures library metadata that contains invalid UTF-8 sequences.

A specific failure was observed on a system where libcrypto.so is symlinked to libcrypto.so.1.1.1wa.

ls -l /usr/lib64/libcrypto.so
lrwxrwxrwx. 1 root root 20 Oct 14 2025 /usr/lib64/libcrypto.so -> libcrypto.so.1.1.1wa

The byte 0xe0 was found in the FIND_PACKAGE_MESSAGE_DETAILS_OpenSSL entry: Hex: ...5b76312e312e31e028295d0a -> Text: ...[v1.1.1\xe0()] In UTF-8, 0xe0 is an invalid continuation byte leading to a crash.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - ✅(Solved) Fix [Build] UnicodeDecodeError in cmake_utils.py due to non-standard library version suffixes (e.g., OpenSSL 1.1.1wa) [1 pull requests, 1 participants]