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
merged 4 commits into from May 20, 2019

Conversation

@domschl
Copy link
Contributor

@domschl domschl commented Apr 27, 2019

find_cuda_config.py crashes, if Unicode chars are found in ldconfig output:

Traceback (most recent call last):
  File "third_party/gpus/find_cuda_config.py", line 463, in <module>
    main()
  File "third_party/gpus/find_cuda_config.py", line 455, in main
    for key, value in sorted(find_cuda_config().items()):
  File "third_party/gpus/find_cuda_config.py", line 418, in find_cuda_config
    _get_default_cuda_paths(cuda_version))
  File "third_party/gpus/find_cuda_config.py", line 159, in _get_default_cuda_paths
    ] + _get_ld_config_paths()
  File "third_party/gpus/find_cuda_config.py", 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/ld.so.cache«, 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
@jeythekey
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))

@domschl
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/ld.so.cache« gefunden
        libzvbi.so.0 (libc6,x86-64) => /usr/lib/libzvbi.so.0
....

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

@jeythekey
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.

@gbaned
Copy link
Contributor

@gbaned gbaned commented May 16, 2019

@skye can you please review this? Thanks!

third_party/gpus/find_cuda_config.py Outdated Show resolved Hide resolved
Copy link
Member

@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
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
Projects
PR Queue
  
Merged
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants