7 of 8 added 49 characters in body

Here is a simplified testcase:

trap '
        trap    - HUP EXIT || exit "$?"
        kill -s HUP    "$$" || exit "$?" ' HUP INT
kill -HUP $$
$ dash dash-bug
dash-bug: 3: /home2/ahq/dash-bug: Syntax error: EOF in backquote substitution

Modifying the length or content of the quoted code may either "fix" the bug or produce different and interesting corruptions, with random bytes appearing out of nowhere.

This was caused by a use-after-free bug which was fixed since dash 0.5.9, but which is still present in the dash 0.5.8 from Debian 9.8 stable (stretch), Ubuntu 18.04 (bionic) and Ubuntu 18.10 (cosmic).

This is the commit which fixed it:

commit 6c3f73bc536082fec38bd36e6c8a121033c68835
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Thu Oct 2 08:26:06 2014 +0800

    [EVAL] Fix use-after-free in dotrap/evalstring

    The function dotrap calls evalstring using the stored trap string.
    If evalstring then unsets that exact trap string then we will end
    up using freed memory.

    This patch fixes it by making evalstring always duplicate the string
    before using it.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>