utils/genrandconfig: fix host-glibc version check (branch yem/gerandconfig-fixups)
cover utils/genrandconfig: fix host-glibc version check (branch yem/gerandconfig-fixups)
Hello All!
This two-patch series does what it says on the tin, and ensures such issues are easier to debug in the future.
Regards,
Yann E. MORIN.
----------------------------------------------------------------
Yann E. MORIN (2):
utils/genrandconfig: fix checking host glibc version utils/genrandconfig: dump traceback for unhandled exceptions
utils/genrandconfig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 1/2 utils/genrandconfig: fix checking host glibc version
Unless explicitly told otherwise, subprocess.check_output() returns bytes objects [0].
When we try to check the C library version (to check the Linaro toolchain is usable), genrandconfig currently fails with:
TypeError: cannot use a string pattern on a bytes-like object
So, as suggested in the python documentation, decocde() the output of subprocess.check_output() before we can use it.
[0] https://docs.python.org/3/library/subprocess.html#subprocess.check_output
--- utils/genrandconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
utils/genrandconfig +1 -1
@@ -181,7 +181,7 @@ def is_toolchain_usable(configfile, config): 'BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64_BE=y\n' in configlines or \ 'BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB=y\n' in configlines: ldd_version_output = subprocess.check_output(['ldd', '--version']) - glibc_version = ldd_version_output.splitlines()[0].split()[-1] + glibc_version = ldd_version_output.decode().splitlines()[0].split()[-1] if StrictVersion('2.14') > StrictVersion(glibc_version): print("WARN: ignoring the Linaro ARM toolchains because too old host glibc", file=sys.stderr) return False
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 1/2] utils/genrandconfig: fix checking host glibc version
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
Unless explicitly told otherwise,
subprocess.check_output()returns bytes objects [0].When we try to check the C library version (to check the Linaro toolchain is usable), genrandconfig currently fails with:
TypeError: cannot use a string pattern on a bytes-like object
Quoted 6 lines
So, as suggested in the python documentation,
decocde()the output ofsubprocess.check_output()before we can use it.[0] https://docs.python.org/3/library/subprocess.html#subprocess.check_output
Signed-off-by Yann E. MORIN <[email protected]>
Committed to 2022.05.x and 2022.02.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/2 utils/genrandconfig: dump traceback for unhandled exceptions
In reply to Yann E. MORINIn case of an unexpected error, we currently only print the exception as an str(). For example, the recent issue with the glibc version check only reported:
TypeError: cannot use a string pattern on a bytes-like object
That does not help in fixing the issue; the exception text is also not usually very user-friendly either anyway.
We change the reporting to print the traceback, which in the glibc version check mentioned above, the error is reported as:
Traceback (most recent call last):
File "./utils/genrandconfig", line 740, in <module>
ret = gen_config(args)
File "./utils/genrandconfig", line 676, in gen_config
if not is_toolchain_usable(configfile, toolchainconfig):
File "./utils/genrandconfig", line 186, in is_toolchain_usable
if StrictVersion('2.14') > StrictVersion(glibc_version):
File "/usr/lib/python3.8/distutils/version.py", line 40, in __init__
self.parse(vstring)
File "/usr/lib/python3.8/distutils/version.py", line 135, in parse
match = self.version_re.match(vstring)
TypeError: cannot use a string pattern on a bytes-like object
With this, the error is much easier to pinpoint (it's the last one that is not in a system module).
--- utils/genrandconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
utils/genrandconfig +3 -2
@@ -25,6 +25,7 @@ import os from random import randint import subprocess import sys +import traceback from distutils.version import StrictVersion import platform
@@ -737,7 +738,7 @@ if __name__ == '__main__': try: ret = gen_config(args) - except Exception as e: - print(str(e), file=sys.stderr) + except Exception: + traceback.print_exc() parser.exit(1) parser.exit(ret)
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/2] utils/genrandconfig: dump traceback for unhandled exceptions
Quoted 26 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
In case of an unexpected error, we currently only print the exception as an
str(). For example, the recent issue with the glibc version check only reported:
TypeError: cannot use a string pattern on a bytes-like objectThat does not help in fixing the issue; the exception text is also not usually very user-friendly either anyway.
We change the reporting to print the traceback, which in the glibc version check mentioned above, the error is reported as:
Traceback (most recent call last):
File "./utils/genrandconfig", line 740, in <module>
ret =gen_config(args)
File "./utils/genrandconfig", line 676, ingen_config
if notis_toolchain_usable(configfile, toolchainconfig):
File "./utils/genrandconfig", line 186, inis_toolchain_usable
if StrictVersion('2.14') >StrictVersion(glibc_version):
File "/usr/lib/python3.8/distutils/version.py", line 40, in__init__
self.parse(vstring)
File "/usr/lib/python3.8/distutils/version.py", line 135, in parse
match =self.version_re.match(vstring)
TypeError: cannot use a string pattern on a bytes-like object
Quoted 4 lines
With this, the error is much easier to pinpoint (it's the last one that is not in a system module).
Signed-off-by Yann E. MORIN <[email protected]>
Committed to 2022.05.x and 2022.02.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 2 lines · On Sun, 21 Aug 2022 10:41:25 +0200 "Yann E. MORIN" <[email protected]>…
utils/genrandconfig: fix checking host glibc version utils/genrandconfig: dump traceback for unhandled exceptions
Both applied to master, thanks!
Peter: these commits should go in 2022.02.x and 2022.05.x. Thanks!
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot