Skip to content

Commit 7affb3b

Browse files
[BACKEND] Ignore bad bytes in ldconfig -p (#7566)
`ldconfig -p` can cause failures on EKS / Ubuntu where ldconfig on /bin/sh is not guaranteed to produce valid utf-8. Just ignore the bad bytes and parsing is still ok. This was the error: ``` libs = subprocess.check_output(["/sbin/ldconfig", "-p"]).decode() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 60334: invalid continuation byte ``` # New contributor declaration Slightly trivial but causing major failures forcing us to parse ldconfig elsewhere with a parser that can handle bad utf-8? - [x] I am not making a trivial change, such as fixing a typo in a comment. - [x] I have written a PR description following these [rules](https://cbea.ms/git-commit/#why-not-how). - [x] I have run `pre-commit run --from-ref origin/main --to-ref HEAD`. - Select one of the following. - [ ] I have added tests. - `/test` for `lit` tests - `/unittest` for C++ tests - `/python/test` for end-to-end tests - [x] This PR does not need a test because `simple parameter addition which just ignores bad chars in python stdlib` - Select one of the following. - [X] I have not added any `lit` tests. - [ ] The `lit` tests I have added follow these [best practices](https://mlir.llvm.org/getting_started/TestingGuide/#filecheck-best-practices), including the "tests should be minimal" section. (Usually running Python code and using the instructions it generates is not minimal.)
1 parent dba750e commit 7affb3b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

third_party/amd/backend/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def _get_path_to_hip_runtime_dylib():
110110
paths.append(f)
111111

112112
# Afterwards try to search the loader dynamic library resolution paths.
113-
libs = subprocess.check_output(["/sbin/ldconfig", "-p"]).decode()
113+
libs = subprocess.check_output(["/sbin/ldconfig", "-p"]).decode(errors="ignore")
114114
# each line looks like the following:
115115
# libamdhip64.so.6 (libc6,x86-64) => /opt/rocm-6.0.2/lib/libamdhip64.so.6
116116
# libamdhip64.so (libc6,x86-64) => /opt/rocm-6.0.2/lib/libamdhip64.so

third_party/nvidia/backend/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def libcuda_dirs():
2222
if env_libcuda_path := knobs.nvidia.libcuda_path:
2323
return [env_libcuda_path]
2424

25-
libs = subprocess.check_output(["/sbin/ldconfig", "-p"]).decode()
25+
libs = subprocess.check_output(["/sbin/ldconfig", "-p"]).decode(errors="ignore")
2626
# each line looks like the following:
2727
# libcuda.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libcuda.so.1
2828
locs = [line.split()[-1] for line in libs.splitlines() if "libcuda.so.1" in line]

0 commit comments

Comments
 (0)