Bug#942799: Stretch: Wrong startup under gdb
Hello Kevin, Am 16.06.21 um 18:03 schrieb Kevin Locke: > On Wed, 2021-06-16 at 09:22 -0600, Kevin Locke wrote: >> I've attached a patch which changes the quoting to fix the issue with >> the hope that you may find it more acceptable than Christophe's patch. > > Please ignore the previous patch. It was sent with insufficient testing > and did not handle the quoting in ${TB_GDB_DEFAULT_OPTS} in the way it > appears to be intended. > > I've attached v2 of the patch which quotes ${TB_ARGS[@]} using > `printf ' %q'` then uses eval to perform word splitting on the combined > command string. In my testing it handled spaces and special characters > in ${TB_GDB_DEFAULT_OPTS} and arguments following -g in the way that I > would expect. See what you think. thanks, looks good to me, will get included within the next upload. -- Regards Carsten
Bug#942799: Stretch: Wrong startup under gdb
On Wed, 2021-06-16 at 09:22 -0600, Kevin Locke wrote: > I've attached a patch which changes the quoting to fix the issue with > the hope that you may find it more acceptable than Christophe's patch. Please ignore the previous patch. It was sent with insufficient testing and did not handle the quoting in ${TB_GDB_DEFAULT_OPTS} in the way it appears to be intended. I've attached v2 of the patch which quotes ${TB_ARGS[@]} using `printf ' %q'` then uses eval to perform word splitting on the combined command string. In my testing it handled spaces and special characters in ${TB_GDB_DEFAULT_OPTS} and arguments following -g in the way that I would expect. See what you think. Cheers, Kevin >From 50bcc2bb310a25fe2a1e6e39528c385c4c98569d Mon Sep 17 00:00:00 2001 Message-Id: <50bcc2bb310a25fe2a1e6e39528c385c4c98569d.1623858686.git.ke...@kevinlocke.name> From: Kevin Locke Date: Wed, 16 Jun 2021 09:08:10 -0600 Subject: [PATCH v2] Fix quoting for -g in thunderbird-wrapper.sh Running `thunderbird -g` produces the following error: INFO -> Starting Thunderbird with GDB ... INFO -> LANG= /usr/bin/gdb -ex "handle SIG38 nostop" -ex "handle SIGPIPE nostop" -ex "run" /usr/lib/thunderbird/thunderbird /usr/bin/thunderbird: line 254: /usr/bin/gdb -ex "handle SIG38 nostop" -ex "handle SIGPIPE nostop" -ex "run" /usr/lib/thunderbird/thunderbird : No such file or directory This occurs because exec is passed a single argument, which it interprets as a file name that does not exist. Instead, use the following steps: 1. Build a command string which combines ${TB_GDB_DEFAULT_OPTS} and ${TB_ARGS[@]} (using `printf ' %q'`). 2. Print the command string with output_info. 3. Run it using `eval` (for word splitting) and `exec` (to replace the shell process with gdb, as before). Signed-off-by: Kevin Locke --- Changes since v1: - Use eval to handle quoting in ${TB_GDB_DEFAULT_OPTS}, since word splitting does not consider quotes in variables. debian/thunderbird-wrapper.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/debian/thunderbird-wrapper.sh b/debian/thunderbird-wrapper.sh index 7546724f136..b76f522654e 100755 --- a/debian/thunderbird-wrapper.sh +++ b/debian/thunderbird-wrapper.sh @@ -250,8 +250,9 @@ else if [ -f /usr/bin/gdb ]; then if dpkg-query -W -f='${Version}' thunderbird-dbgsym &>/dev/null ; then output_info "Starting Thunderbird with GDB ..." -output_info "LANG= /usr/bin/gdb ${TB_GDB_DEFAULT_OPTS} -ex \"run\" ${MOZ_LIBDIR}/${MOZ_APP_NAME} ${TB_ARGS[@]}" -LANG='' exec "/usr/bin/gdb ${TB_GDB_DEFAULT_OPTS} -ex \"run\" ${MOZ_LIBDIR}/${MOZ_APP_NAME} ${TB_ARGS[@]}" +TB_ARGS_LINE="/usr/bin/gdb ${TB_GDB_DEFAULT_OPTS} -ex run ${MOZ_LIBDIR}/${MOZ_APP_NAME}$(printf ' %q' "${TB_ARGS[@]}")" +output_info "LANG= $TB_ARGS_LINE" +LANG='' eval "exec $TB_ARGS_LINE" else output_info "No package 'thunderbird-dbgsym' installed! Please install first and restart." output_info "More information how to adjust your sources.list to being able installing" -- 2.30.2
Bug#942799: Stretch: Wrong startup under gdb
On Mon, 2019-10-21 at 19:53 +0200, Carsten Schoenert wrote: > Am 21.10.19 um 19:40 schrieb Christophe DELAHAYE: >> I tried to run Thunderbird under GDB to characterize a crash, but the >> command line built by the start script is wrong. > > could you give please an example what is going wrong. > This part of the script was tested several times so before I will apply > any patch I need to understand what is causing issues. I am able to reproduce the issue with thunderbird 1:78.11.0-1 by running `thunderbird -g` which prints: INFO -> Starting Thunderbird with GDB ... INFO -> LANG= /usr/bin/gdb -ex "handle SIG38 nostop" -ex "handle SIGPIPE nostop" -ex "run" /usr/lib/thunderbird/thunderbird /usr/bin/thunderbird: line 254: /usr/bin/gdb -ex "handle SIG38 nostop" -ex "handle SIGPIPE nostop" -ex "run" /usr/lib/thunderbird/thunderbird : No such file or directory Then exits with code 127. The issue occurs because exec is passed a single argument on line 254, which bash interprets as a path that does not exist. I've attached a patch which changes the quoting to fix the issue with the hope that you may find it more acceptable than Christophe's patch. Thanks for considering, Kevin >From 119b82022ef8887aea70b0104922a38ce9e020cb Mon Sep 17 00:00:00 2001 Message-Id: <119b82022ef8887aea70b0104922a38ce9e020cb.1623856383.git.ke...@kevinlocke.name> From: Kevin Locke Date: Wed, 16 Jun 2021 09:08:10 -0600 Subject: [PATCH] Fix quoting for -g in thunderbird-wrapper.sh Running `thunderbird -g` produces the following error: INFO -> Starting Thunderbird with GDB ... INFO -> LANG= /usr/bin/gdb -ex "handle SIG38 nostop" -ex "handle SIGPIPE nostop" -ex "run" /usr/lib/thunderbird/thunderbird /usr/bin/thunderbird: line 254: /usr/bin/gdb -ex "handle SIG38 nostop" -ex "handle SIGPIPE nostop" -ex "run" /usr/lib/thunderbird/thunderbird : No such file or directory This occurs because exec is passed a single argument, which it interprets as a file name that does not exist. Remove the surrounding quotes so that each argument is passed separately. Signed-off-by: Kevin Locke --- debian/thunderbird-wrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/thunderbird-wrapper.sh b/debian/thunderbird-wrapper.sh index 7546724f136..2e088812b72 100755 --- a/debian/thunderbird-wrapper.sh +++ b/debian/thunderbird-wrapper.sh @@ -251,7 +251,7 @@ else if dpkg-query -W -f='${Version}' thunderbird-dbgsym &>/dev/null ; then output_info "Starting Thunderbird with GDB ..." output_info "LANG= /usr/bin/gdb ${TB_GDB_DEFAULT_OPTS} -ex \"run\" ${MOZ_LIBDIR}/${MOZ_APP_NAME} ${TB_ARGS[@]}" -LANG='' exec "/usr/bin/gdb ${TB_GDB_DEFAULT_OPTS} -ex \"run\" ${MOZ_LIBDIR}/${MOZ_APP_NAME} ${TB_ARGS[@]}" +LANG='' exec /usr/bin/gdb ${TB_GDB_DEFAULT_OPTS} -ex run "${MOZ_LIBDIR}/${MOZ_APP_NAME}" "${TB_ARGS[@]}" else output_info "No package 'thunderbird-dbgsym' installed! Please install first and restart." output_info "More information how to adjust your sources.list to being able installing" -- 2.30.2
Bug#942799: Stretch: Wrong startup under gdb
A few details about the error: when running "bash -x /usr/bin/thunderbird -g", the command trace ends as follows: - + output_info 'Starting Thunderbird with GDB ...' + echo 'INFO -> Starting Thunderbird with GDB ...' INFO -> Starting Thunderbird with GDB ... + output_info 'LANG= /usr/bin/gdb -ex handle SIG38 nostop -ex handle SIGPIPE nostop -ex run /usr/lib/thunderbird/thunderbird ' + echo 'INFO -> LANG= /usr/bin/gdb -ex handle SIG38 nostop -ex handle SIGPIPE nostop -ex run /usr/lib/thunderbird/thunderbird ' INFO -> LANG= /usr/bin/gdb -ex handle SIG38 nostop -ex handle SIGPIPE nostop -ex run /usr/lib/thunderbird/thunderbird + LANG= + exec '/usr/bin/gdb -ex handle SIG38 nostop -ex handle SIGPIPE nostop -ex run /usr/lib/thunderbird/thunderbird ' /usr/bin/thunderbird: line 249: /usr/bin/gdb -ex handle SIG38 nostop -ex handle SIGPIPE nostop -ex run /usr/lib/thunderbird/thunderbird : No such file or directory - It seems that the whole command line is interpreted as the filename to load. I did not recorded the shell exit status, but I believe that I saw 127, the usual code for "command not found". I also think that I experimented some problems with the "-ex" options when I tried to split this long exec argument into filename and arguments. Hence the proposed patch replaces this complex command line with a simple one and a temporary file containing the commands for Gdb. Note: the crash mentioned in the initial report is not the problem, only the motivation to run Thunderbird under Gdb. Regards.
Bug#942799: Stretch: Wrong startup under gdb
Hello Christophe, Am 21.10.19 um 19:40 schrieb Christophe DELAHAYE: > Package: thunderbird > Version: 1:60.9.0-1~deb9u1 > Severity: minor > Tags: patch > > Hello. > > I tried to run Thunderbird under GDB to characterize a crash, but the > command line built by the start script is wrong. could you give please an example what is going wrong. This part of the script was tested several times so before I will apply any patch I need to understand what is causing issues. We need to take care of for now three releases repositories and of course we don't want to differ more than needed. -- Regards Carsten Schoenert