git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Issues with git send-email and msmtp
@ 2017-03-21 15:49 Roger Pau Monné
  2017-03-21 16:50 ` Jeff King
  2017-03-22  9:47 ` Roger Pau Monné
  0 siblings, 2 replies; 4+ messages in thread
From: Roger Pau Monné @ 2017-03-21 15:49 UTC (permalink / raw)
  To: git

Hello,

I'm trying to use git send-email with msmtp, and I have added the following to
my .gitconfig:

[sendemail]
	smtpserver = "/usr/local/bin/msmtp"

This seems to work fine, except that sometimes git dies unexpectedly after
queuing a patch to msmtp:

Died at /usr/local/Cellar/git/2.12.0/libexec/git-core/git-send-email line 1350, <FIN> line 3.

I'm guessing there's some kind of race, because this is not 100% reproducible,
sometimes succeeds while others simply dies with the above message. As you can
imagine, this is specially annoying when sending patch series.

Has someone seen similar issues when using send-email and msmtp? Am I missing
something in my .gitconfig?

Thanks, Roger.

(please keep me in the Cc since I'm not subscribed)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Issues with git send-email and msmtp
  2017-03-21 15:49 Issues with git send-email and msmtp Roger Pau Monné
@ 2017-03-21 16:50 ` Jeff King
  2017-03-21 19:23   ` Eric Wong
  2017-03-22  9:47 ` Roger Pau Monné
  1 sibling, 1 reply; 4+ messages in thread
From: Jeff King @ 2017-03-21 16:50 UTC (permalink / raw)
  To: Roger Pau Monné; +Cc: git

On Tue, Mar 21, 2017 at 03:49:21PM +0000, Roger Pau Monné wrote:

> I'm trying to use git send-email with msmtp, and I have added the following to
> my .gitconfig:
> 
> [sendemail]
> 	smtpserver = "/usr/local/bin/msmtp"
> 
> This seems to work fine, except that sometimes git dies unexpectedly after
> queuing a patch to msmtp:
> 
> Died at /usr/local/Cellar/git/2.12.0/libexec/git-core/git-send-email line 1350, <FIN> line 3.

That line looks like it's the "close" on the pipe. If it's dying racily
that could mean that msmtp for some reason is not eating all of the
data and we're getting EPIPE (though that seems weird, since we're just
dumping the message until EOF). Or possibly msmtp is sometimes exiting
non-zero.

Capturing an "strace" for a failing run would be helpful. If that's not
possible, something like this patch might help diagnose it:

diff --git a/git-send-email.perl b/git-send-email.perl
index eea0a517f..32d34f995 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1346,7 +1346,10 @@ EOF
 			exec($smtp_server, @sendmail_parameters) or die $!;
 		}
 		print $sm "$header\n$message";
-		close $sm or die $!;
+		if (!close($sm)) {
+			die $! ? "unable to write to $smtp_server: $!"
+			       : "smtp program '$smtp_server' exited non-zero: $?"
+		}
 	} else {
 
 		if (!defined $smtp_server) {

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Issues with git send-email and msmtp
  2017-03-21 16:50 ` Jeff King
@ 2017-03-21 19:23   ` Eric Wong
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2017-03-21 19:23 UTC (permalink / raw)
  To: Roger Pau Monné, Jeff King; +Cc: git

Jeff King <peff@peff.net> wrote:
> On Tue, Mar 21, 2017 at 03:49:21PM +0000, Roger Pau Monné wrote:
> 
> > I'm trying to use git send-email with msmtp, and I have added the following to
> > my .gitconfig:
> > 
> > [sendemail]
> > 	smtpserver = "/usr/local/bin/msmtp"
> > 
> > This seems to work fine, except that sometimes git dies unexpectedly after
> > queuing a patch to msmtp:
> > 
> > Died at /usr/local/Cellar/git/2.12.0/libexec/git-core/git-send-email line 1350, <FIN> line 3.

Hi Roger, can you also enable msmtp logging and debugging?

logfile /path/to/log # in ~/.msmtprc
And "msmtp --debug" in the command line

> That line looks like it's the "close" on the pipe. If it's dying racily
> that could mean that msmtp for some reason is not eating all of the
> data and we're getting EPIPE (though that seems weird, since we're just
> dumping the message until EOF). Or possibly msmtp is sometimes exiting
> non-zero.
> 
> Capturing an "strace" for a failing run would be helpful. If that's not
> possible, something like this patch might help diagnose it:
> 
> diff --git a/git-send-email.perl b/git-send-email.perl
> index eea0a517f..32d34f995 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -1346,7 +1346,10 @@ EOF
>  			exec($smtp_server, @sendmail_parameters) or die $!;
>  		}
>  		print $sm "$header\n$message";

Perhaps also:

		print $sm "$header\n$message" or
				die "print failed to $smtp_server: $!";

> -		close $sm or die $!;
> +		if (!close($sm)) {
> +			die $! ? "unable to write to $smtp_server: $!"
> +			       : "smtp program '$smtp_server' exited non-zero: $?"

Parentheses please :>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Issues with git send-email and msmtp
  2017-03-21 15:49 Issues with git send-email and msmtp Roger Pau Monné
  2017-03-21 16:50 ` Jeff King
@ 2017-03-22  9:47 ` Roger Pau Monné
  1 sibling, 0 replies; 4+ messages in thread
From: Roger Pau Monné @ 2017-03-22  9:47 UTC (permalink / raw)
  To: git

On Tue, Mar 21, 2017 at 03:49:21PM +0000, Roger Pau Monné wrote:
> Hello,
> 
> I'm trying to use git send-email with msmtp, and I have added the following to
> my .gitconfig:
> 
> [sendemail]
> 	smtpserver = "/usr/local/bin/msmtp"
> 
> This seems to work fine, except that sometimes git dies unexpectedly after
> queuing a patch to msmtp:
> 
> Died at /usr/local/Cellar/git/2.12.0/libexec/git-core/git-send-email line 1350, <FIN> line 3.
> 
> I'm guessing there's some kind of race, because this is not 100% reproducible,
> sometimes succeeds while others simply dies with the above message. As you can
> imagine, this is specially annoying when sending patch series.
> 
> Has someone seen similar issues when using send-email and msmtp? Am I missing
> something in my .gitconfig?

(switched to my @citrix.com address to prevent further bounces)

Hello,

Thanks for the help, and sorry to reply here (as some of you noted the
forwarding from address with SPF was broken and messages bounced). It seems
like this is a msmtp issue, more exactly msmtp doesn't handle SIGPIPE, and
AFAICT this leads to crashes when the server closes the connection before msmtp
does:

* thread #1: [...] stop reason = signal SIGPIPE
    frame #0: 0x00007fffd5c4d00a libsystem_kernel.dylib`__sendmsg + 10
libsystem_kernel.dylib`__sendmsg:
[...]
(lldb) bt
* thread #1: tid = 0x87c0f4, 0x00007fffd5c4d00a libsystem_kernel.dylib`__sendmsg + 10, queue = 'com.apple.main-thread', stop reason = signal SIGPIPE
  * frame #0: 0x00007fffd5c4d00a libsystem_kernel.dylib`__sendmsg + 10
    frame #1: 0x0000000101e5c69c libgnutls.30.dylib`system_writev + 41
    frame #2: 0x0000000101e3d1ba libgnutls.30.dylib`_gnutls_io_write_flush + 428
    frame #3: 0x0000000101e37689 libgnutls.30.dylib`_gnutls_send_tlen_int + 1222
    frame #4: 0x0000000101e5b78a libgnutls.30.dylib`gnutls_alert_send + 124
    frame #5: 0x0000000101e36f4f libgnutls.30.dylib`gnutls_bye + 86
    frame #6: 0x0000000101e1e8bc msmtp`tls_close([...]) + 28 at tls.c:1736 [opt]
    frame #7: 0x0000000101e1c382 msmtp`smtp_close([...]) + 34 at smtp.c:1905 [opt]
    frame #8: 0x0000000101e136ab msmtp`msmtp_sendmail [inlined] msmtp_endsession([...]) + 53 at msmtp.c:555 [opt]
    frame #9: 0x0000000101e13676 msmtp`msmtp_sendmail([...]) + 1558 at msmtp.c:1913 [opt]
    frame #10: 0x0000000101e183e6 msmtp`main([...]) + 5094 at msmtp.c:4157 [opt]
    frame #11: 0x00007fffd5b1e255 libdyld.dylib`start + 1
(lldb) c
Process 70391 resuming
Process 70391 exited with status = 0 (0x00000000) Terminated due to signal 13

This has nothing to do with git, I probably didn't realize before because I
guess mutt ignores this completely. I already sent a patch upstream.

Roger.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-22  9:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-21 15:49 Issues with git send-email and msmtp Roger Pau Monné
2017-03-21 16:50 ` Jeff King
2017-03-21 19:23   ` Eric Wong
2017-03-22  9:47 ` Roger Pau Monné

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).