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
Merged

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

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.

@tensorflow-bot tensorflow-bot bot added the size:XS CL Change Size: Extra Small label Apr 27, 2019
@gbaned gbaned self-assigned this Apr 27, 2019
@gbaned gbaned requested a review from skye April 27, 2019 09:59
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation Apr 27, 2019
@jeythekey
Copy link

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 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 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 commented May 16, 2019

@skye can you please review this? Thanks!

skye
skye previously approved these changes May 16, 2019
Copy link
Member

@skye skye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending the one comment.

PR Queue automation moved this from Assigned Reviewer to Approved by Reviewer May 16, 2019
@tensorflow-bot tensorflow-bot bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels May 16, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label May 16, 2019
PR Queue automation moved this from Approved by Reviewer to Reviewer Requested Changes May 17, 2019
PR Queue automation moved this from Reviewer Requested Changes to Approved by Reviewer May 17, 2019
@tensorflow-bot tensorflow-bot bot added the kokoro:force-run Tests on submitted change label May 17, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label May 17, 2019
@tensorflow-copybara tensorflow-copybara merged commit ef59a95 into tensorflow:master May 20, 2019
PR Queue automation moved this from Approved by Reviewer to Merged May 20, 2019
tensorflow-copybara pushed a commit that referenced this pull request May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes ready to pull PR ready for merge process size:XS CL Change Size: Extra Small
Projects
PR Queue
  
Merged
Development

Successfully merging this pull request may close these issues.

None yet

7 participants