GNU bug report logs - #27704
[PATCH] daemon: Show actual rather than collateral error when export fails.

Previous Next

Package: guix-patches;

Reported by: Jan Nieuwenhuizen <janneke <at> gnu.org>

Date: Sat, 15 Jul 2017 11:00:02 UTC

Severity: normal

Tags: patch

Done: ludo <at> gnu.org (Ludovic Courtès)

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27704 in the body.
You can then email your comments to 27704 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#27704; Package guix-patches. (Sat, 15 Jul 2017 11:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jan Nieuwenhuizen <janneke <at> gnu.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sat, 15 Jul 2017 11:00:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jan Nieuwenhuizen <janneke <at> gnu.org>
To: guix-patches <at> gnu.org
Subject: [PATCH] daemon: Show actual rather than collateral error when export
 fails.
Date: Sat, 15 Jul 2017 12:58:51 +0200
Having the wrong permissions on /etc/guix/signing-key.sec gives

    guix-daemon: nix/libutil/serialise.cc:15: virtual nix::BufferedSink::~BufferedSink(): Assertion `!bufPos' failed.

this patch changes that to

    guix-daemon: error: file `/etc/guix/signing-key.sec' should be secret (inaccessible to everybody else)!

* nix/nix-daemon/nix-daemon.cc (performOp): Catch any exportPath exception,
report and exit on that.  Fixes failing later with uninformative collateral error.
---
 nix/nix-daemon/nix-daemon.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc
index 7d26b6135..aeeadf144 100644
--- a/nix/nix-daemon/nix-daemon.cc
+++ b/nix/nix-daemon/nix-daemon.cc
@@ -436,7 +436,13 @@ static void performOp(bool trusted, unsigned int clientVersion,
         bool sign = readInt(from) == 1;
         startWork();
         TunnelSink sink(to);
-        store->exportPath(path, sign, sink);
+        try {
+            store->exportPath(path, sign, sink);
+        }
+        catch (std::exception &e) {
+            fprintf (stderr, "guix-daemon: error: %s\n", e.what ());
+            exit (EXIT_FAILURE);
+        }
         sink.flush();
         stopWork();
         writeInt(1, to);
-- 
Jan Nieuwenhuizen <janneke <at> gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com





Information forwarded to guix-patches <at> gnu.org:
bug#27704; Package guix-patches. (Mon, 17 Jul 2017 09:48:02 GMT) Full text and rfc822 format available.

Message #8 received at 27704 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Jan Nieuwenhuizen <janneke <at> gnu.org>
Cc: 27704 <at> debbugs.gnu.org
Subject: Re: [bug#27704] [PATCH] daemon: Show actual rather than collateral
 error when export fails.
Date: Mon, 17 Jul 2017 11:47:04 +0200
Hello,

Jan Nieuwenhuizen <janneke <at> gnu.org> skribis:

> Having the wrong permissions on /etc/guix/signing-key.sec gives
>
>     guix-daemon: nix/libutil/serialise.cc:15: virtual nix::BufferedSink::~BufferedSink(): Assertion `!bufPos' failed.
>
> this patch changes that to
>
>     guix-daemon: error: file `/etc/guix/signing-key.sec' should be secret (inaccessible to everybody else)!
>
> * nix/nix-daemon/nix-daemon.cc (performOp): Catch any exportPath exception,
> report and exit on that.  Fixes failing later with uninformative collateral error.

Good catch!

> --- a/nix/nix-daemon/nix-daemon.cc
> +++ b/nix/nix-daemon/nix-daemon.cc
> @@ -436,7 +436,13 @@ static void performOp(bool trusted, unsigned int clientVersion,
>          bool sign = readInt(from) == 1;
>          startWork();
>          TunnelSink sink(to);
> -        store->exportPath(path, sign, sink);
> +        try {
> +            store->exportPath(path, sign, sink);
> +        }
> +        catch (std::exception &e) {
> +            fprintf (stderr, "guix-daemon: error: %s\n", e.what ());
> +            exit (EXIT_FAILURE);

I think we should simply do:

  sink.flush();
  throw e;

in the ‘catch’ handler.

That way, we won’t have the assertion failure, and yet the error will
correctly propagate to the client without forcing a disconnect.

Could you check if that works as expected?

Thank you!

Ludo’.




Reply sent to ludo <at> gnu.org (Ludovic Courtès):
You have taken responsibility. (Mon, 17 Jul 2017 13:16:02 GMT) Full text and rfc822 format available.

Notification sent to Jan Nieuwenhuizen <janneke <at> gnu.org>:
bug acknowledged by developer. (Mon, 17 Jul 2017 13:16:02 GMT) Full text and rfc822 format available.

Message #13 received at 27704-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Jan Nieuwenhuizen <janneke <at> gnu.org>
Cc: 27704-done <at> debbugs.gnu.org
Subject: Re: [bug#27704] [PATCH] daemon: Show actual rather than collateral
 error when export fails.
Date: Mon, 17 Jul 2017 15:15:01 +0200
ludo <at> gnu.org (Ludovic Courtès) skribis:

> Hello,
>
> Jan Nieuwenhuizen <janneke <at> gnu.org> skribis:
>
>> Having the wrong permissions on /etc/guix/signing-key.sec gives
>>
>>     guix-daemon: nix/libutil/serialise.cc:15: virtual nix::BufferedSink::~BufferedSink(): Assertion `!bufPos' failed.
>>
>> this patch changes that to
>>
>>     guix-daemon: error: file `/etc/guix/signing-key.sec' should be secret (inaccessible to everybody else)!
>>
>> * nix/nix-daemon/nix-daemon.cc (performOp): Catch any exportPath exception,
>> report and exit on that.  Fixes failing later with uninformative collateral error.
>
> Good catch!
>
>> --- a/nix/nix-daemon/nix-daemon.cc
>> +++ b/nix/nix-daemon/nix-daemon.cc
>> @@ -436,7 +436,13 @@ static void performOp(bool trusted, unsigned int clientVersion,
>>          bool sign = readInt(from) == 1;
>>          startWork();
>>          TunnelSink sink(to);
>> -        store->exportPath(path, sign, sink);
>> +        try {
>> +            store->exportPath(path, sign, sink);
>> +        }
>> +        catch (std::exception &e) {
>> +            fprintf (stderr, "guix-daemon: error: %s\n", e.what ());
>> +            exit (EXIT_FAILURE);
>
> I think we should simply do:
>
>   sink.flush();
>   throw e;
>
> in the ‘catch’ handler.

I’ve confirmed that it works as expected.

Pushed as 2e009ae7cdaee4ce871b3a79d50118762ee29fb6, thanks again!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 15 Aug 2017 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 1 day ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.