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

find_cuda: fix crash caused by unicode chars in ldconfig output #28209

merged 4 commits into from May 20, 2019


Copy link

@domschl domschl commented Apr 27, 2019 crashes, if Unicode chars are found in ldconfig output:

Traceback (most recent call last):
  File "third_party/gpus/", line 463, in <module>
  File "third_party/gpus/", line 455, in main
    for key, value in sorted(find_cuda_config().items()):
  File "third_party/gpus/", line 418, in find_cuda_config
  File "third_party/gpus/", line 159, in _get_default_cuda_paths
    ] + _get_ld_config_paths()
  File "third_party/gpus/", line 139, in _get_ld_config_paths
    match = pattern.match(line.decode("ascii"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 27: ordinal not in range(128)
Asking for detailed CUDA configuration...

Localized versions of ldconfig versions use Unicode chars, e.g.: »/etc/«, causing the crash.

The fix simply skips lines with Unicode chars.

@gbaned gbaned self-assigned this Apr 27, 2019
@gbaned gbaned requested a review from skye Apr 27, 2019
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation Apr 27, 2019
Copy link

@jeythekey jeythekey commented May 8, 2019

This line also fixed it for me, don't know if it is a (more?) generic one:
match = pattern.match(line.decode(sys.stdin.encoding))

Copy link
Contributor Author

@domschl domschl commented May 8, 2019

Yes, that would fix the encoding generally. So I would be happy with this too.
It could potentially unleash Unicode-filled paths on the rest of the software, if someone would use those, not sure if that would be a problem.
In most cases it seems just the first line of the output of ldconfig -p, the header-line, that causes the problem, since it is the only part that is localized and thus can contain Unicode chars:

4403 Bibliotheken im Cache »/etc/« gefunden (libc6,x86-64) => /usr/lib/

E.g. for German locale, the chars » and « in the header cause the issue.

Copy link

@jeythekey jeythekey commented May 8, 2019

Yes, that was probably also the case in my case ;) Funnily only when calling ./configure from the command line, not when executing the code in ipython or spyder.

Copy link

@gbaned gbaned commented May 16, 2019

@skye can you please review this? Thanks!

third_party/gpus/ Outdated Show resolved Hide resolved
Copy link

@skye skye left a comment

LGTM pending the one comment.

PR Queue automation moved this from Assigned Reviewer to Approved by Reviewer May 16, 2019
PR Queue automation moved this from Approved by Reviewer to Reviewer Requested Changes May 17, 2019
skye approved these changes May 17, 2019
PR Queue automation moved this from Reviewer Requested Changes to Approved by Reviewer May 17, 2019
@tensorflow-copybara tensorflow-copybara merged commit ef59a95 into tensorflow:master May 20, 2019
13 of 15 checks passed
PR Queue automation moved this from Approved by Reviewer to Merged May 20, 2019
tensorflow-copybara pushed a commit that referenced this issue May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
PR Queue
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants