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

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 label Apr 27, 2019
@googlebot googlebot added the cla: yes label Apr 27, 2019
@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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented May 16, 2019

@skye can you please review this? Thanks!

Copy link
Member

left a comment

LGTM pending the one comment.

PR Queue automation moved this from Assigned Reviewer to Approved by Reviewer May 16, 2019
domschl added 2 commits May 17, 2019
UnicodeDecodeError added.
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
13 of 15 checks passed
Linux GPU Internal CI build failed
Details
Windows Bazel GPU Internal CI build failed
Details
Android Demo App Internal CI build successful
Details
MacOS Contrib Internal CI build successful
Details
MacOS Python2 and CC Internal CI build successful
Details
Ubuntu CC Internal CI build successful
Details
Ubuntu Makefile Internal CI build successful
Details
Ubuntu Python2 Internal CI build successful
Details
Ubuntu Python3 Internal CI build successful
Details
Ubuntu Python3 PIP Internal CI build successful
Details
Ubuntu Sanity Internal CI build successful
Details
Ubuntu contrib Internal CI build successful
Details
Windows Bazel Internal CI build successful
Details
cla/google All necessary CLAs are signed
import/copybara Change imported to the internal review system
Details
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
PiperOrigin-RevId: 249072380
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PR Queue
  
Merged
7 participants
You can’t perform that action at this time.