Patchwork [v2] util/error: do not free error on error_abort

login
register
mail settings
Submitter Vladimir Sementsov-Ogievskiy
Date April 15, 2019, 2:25 p.m.
Message ID <20190415142519.73060-1-vsementsov@virtuozzo.com>
Download mbox | patch
Permalink /patch/773185/
State New
Headers show

Comments

Vladimir Sementsov-Ogievskiy - April 15, 2019, 2:25 p.m.
It would be nice to have Error object not freed away when debugging a
coredump.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---

v2: don't change error output format

 util/error.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Markus Armbruster - April 17, 2019, 5:16 p.m.
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:

> It would be nice to have Error object not freed away when debugging a
> coredump.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>
> v2: don't change error output format
>
>  util/error.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/util/error.c b/util/error.c
> index 934a78e1b1..22f8a7924f 100644
> --- a/util/error.c
> +++ b/util/error.c
> @@ -34,7 +34,10 @@ static void error_handle_fatal(Error **errp, Error *err)
>      if (errp == &error_abort) {
>          fprintf(stderr, "Unexpected error in %s() at %s:%d:\n",
>                  err->func, err->src, err->line);
> -        error_report_err(err);
> +        error_report("%s", error_get_pretty(err));
> +        if (err->hint) {
> +            error_printf_unless_qmp("%s", err->hint->str);
> +        }
>          abort();
>      }
>      if (errp == &error_fatal) {

We've since found out that the hint should be printed with
error_printf(), see "[PATCH] error: Fix error_report_err(),
warn_report_err() hint printing".  With that:

Reviewed-by: Markus Armbruster <armbru@redhat.com>

Queued with this change.  Thanks!

Patch

diff --git a/util/error.c b/util/error.c
index 934a78e1b1..22f8a7924f 100644
--- a/util/error.c
+++ b/util/error.c
@@ -34,7 +34,10 @@  static void error_handle_fatal(Error **errp, Error *err)
     if (errp == &error_abort) {
         fprintf(stderr, "Unexpected error in %s() at %s:%d:\n",
                 err->func, err->src, err->line);
-        error_report_err(err);
+        error_report("%s", error_get_pretty(err));
+        if (err->hint) {
+            error_printf_unless_qmp("%s", err->hint->str);
+        }
         abort();
     }
     if (errp == &error_fatal) {