~sircmpwn/aerc

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 3

panic: runtime error: invalid memory address or nil pointer dereference

Details
Message ID
<CELLSBG5K43U.1XB1MGUBKRO4V@dizzy>
DKIM signature
pass
Download raw message
This happened when I was composing an email with neovim:

```
> aerc 
panic: runtime error: invalid memory address or nil pointer dereference 
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x564def548487] 
goroutine 1 [running]: 
git.sr.ht/~sircmpwn/aerc/widgets.(*MessageList).Draw(0xc0002b5da0, 0xc0000d6c60) 
        git.sr.ht/~sircmpwn/aerc/widgets/msglist.go:108 +0x767 
git.sr.ht/~sircmpwn/aerc/lib/ui.(*Grid).Draw(0xc0001c06e0, 0xc0000d6a20) 
        git.sr.ht/~sircmpwn/aerc/lib/ui/grid.go:144 +0x277 
git.sr.ht/~sircmpwn/aerc/widgets.(*AccountView).Draw(0xc0002f4e70, 0xc0000d6a20) 
        git.sr.ht/~sircmpwn/aerc/widgets/account.go:139 +0x3b 
git.sr.ht/~sircmpwn/aerc/lib/ui.(*TabContent).Draw(0xc0002f4e00, 0xc0000d6a20) 
        git.sr.ht/~sircmpwn/aerc/lib/ui/tab.go:394 +0x7c 
git.sr.ht/~sircmpwn/aerc/lib/ui.(*Grid).Draw(0xc0001c0580, 0xc000416120) 
        git.sr.ht/~sircmpwn/aerc/lib/ui/grid.go:144 +0x277 
git.sr.ht/~sircmpwn/aerc/widgets.(*Aerc).Draw(0xc0001c0630, 0xc000416120) 
        git.sr.ht/~sircmpwn/aerc/widgets/aerc.go:176 +0x3f 
git.sr.ht/~sircmpwn/aerc/lib/ui.(*UI).Tick(0xc00043e000, 0x564def5b0e00) 
        git.sr.ht/~sircmpwn/aerc/lib/ui/ui.go:113 +0x1d1 
main.main() 
        git.sr.ht/~sircmpwn/aerc/aerc.go:194 +0x6b3 
```

I am not a go programmer but any leads to what exactly might have
happened are appreciated. I will try to fiddle with the problem.

```
> aerc -v 
aerc 0.5.2 
```
Details
Message ID
<2638128.mvXUDI8C0e@wunka>
In-Reply-To
<CELLSBG5K43U.1XB1MGUBKRO4V@dizzy> (view parent)
DKIM signature
pass
Download raw message
On вторник, 28 септември 2021 г. 17:54:45 ч. EEST Bill wrote:
> panic: runtime error: invalid memory address or nil pointer dereference
> [signal SIGSEGV: segmentation violation code=0x1 addr=0x18
> pc=0x564def548487] goroutine 1 [running]:
> git.sr.ht/~sircmpwn/aerc/widgets.(*MessageList).Draw(0xc0002b5da0,
> 0xc0000d6c60) git.sr.ht/~sircmpwn/aerc/widgets/msglist.go:108 +0x767

This has been fixed in master, but yet to be released: https://git.sr.ht/
~sircmpwn/aerc/commit/3c14c2cb3494766d39e22c852a6a8f8b965dea92
Details
Message ID
<yvo8eNhewwmI3IlsFCiXWTZ7r2Wn2Fi-oLUOkommPWV2bURa06sKjsn8Rt0SQXjfGHVo22f2CuWb7FaDbEzIC8UwZOKS9R-rTI1pWZPeXuo=@hispagatos.org>
In-Reply-To
<2638128.mvXUDI8C0e@wunka> (view parent)
DKIM signature
pass
Download raw message
I am still having this segfaul daily.. I leave aerc on 24/7 and every single day I have to restart it because of this..

aerc -v                                                                                                               ░▒▓ ✔  at 19:24:12  

aerc 0.5.2.r50.g0b19b5e

```
goroutine 1 [running]:                                                                                                         ░▒▓ ✔  at 16:27:35  

runtime/debug.Stack()
	runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
	runtime/debug/stack.go:16 +0x19
main.PanicTermFix(0x0)
	git.sr.ht/~sircmpwn/aerc/aerc.go:212 +0x45
panic({0x55b23cd32920, 0x55b23d0b1330})
	runtime/panic.go:1047 +0x266
git.sr.ht/~sircmpwn/aerc/lib/format.ParseMessageFormat({0xc0001a4258, 0x11}, {0xc0001a4270, 0x10}, {{0xc000124751, 0x20}, {0xc000118b30, 0xa}, 0x342, 0xc0000a8500, ...})
	git.sr.ht/~sircmpwn/aerc/lib/format/format.go:149 +0x925
git.sr.ht/~sircmpwn/aerc/widgets.(*MessageList).Draw(0xc0003a84e0, 0xc000325320)
	git.sr.ht/~sircmpwn/aerc/widgets/msglist.go:156 +0xf08
git.sr.ht/~sircmpwn/aerc/lib/ui.(*Grid).Draw(0xc0003ea210, 0xc000325260)
	git.sr.ht/~sircmpwn/aerc/lib/ui/grid.go:144 +0x2ef
git.sr.ht/~sircmpwn/aerc/widgets.(*AccountView).Draw(0x203000, 0x0)
	git.sr.ht/~sircmpwn/aerc/widgets/account.go:139 +0x1d
git.sr.ht/~sircmpwn/aerc/lib/ui.(*TabContent).Draw(0xc000090000, 0x0)
	git.sr.ht/~sircmpwn/aerc/lib/ui/tab.go:394 +0x143
git.sr.ht/~sircmpwn/aerc/lib/ui.(*Grid).Draw(0xc0003ea000, 0xc000090000)
	git.sr.ht/~sircmpwn/aerc/lib/ui/grid.go:144 +0x2ef
git.sr.ht/~sircmpwn/aerc/widgets.(*Aerc).Draw(0xc0003ea0b0, 0xc000090000)
	git.sr.ht/~sircmpwn/aerc/widgets/aerc.go:177 +0x2e
git.sr.ht/~sircmpwn/aerc/lib/ui.(*UI).Tick(0xc00009c000)
	git.sr.ht/~sircmpwn/aerc/lib/ui/ui.go:113 +0x1f7
main.main()
	git.sr.ht/~sircmpwn/aerc/aerc.go:197 +0xa0c
aerc crashed: runtime error: invalid memory address or nil pointer dereference
```
Happy Hacking
ReK2


Salut
ReK2 ReK2WiLdS BBK
rek2@hispagatos.org
https://hispagatos.org
https://hispagatos.space
gemini://rek2.hispagatos.org
gemini://hispagatos.org

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

El jueves, 30 de septiembre de 2021 a las 21:26, Kiril Vladimirov <kiril@vladimiroff.org> escribió:

> On вторник, 28 септември 2021 г. 17:54:45 ч. EEST Bill wrote:
> 

> > panic: runtime error: invalid memory address or nil pointer dereference
> > 

> > [signal SIGSEGV: segmentation violation code=0x1 addr=0x18
> > 

> > pc=0x564def548487] goroutine 1 [running]:
> > 

> > git.sr.ht/~sircmpwn/aerc/widgets.(*MessageList).Draw(0xc0002b5da0,
> > 

> > 0xc0000d6c60) git.sr.ht/~sircmpwn/aerc/widgets/msglist.go:108 +0x767
> 

> This has been fixed in master, but yet to be released: https://git.sr.ht/
> 

> ~sircmpwn/aerc/commit/3c14c2cb3494766d39e22c852a6a8f8b965dea92

[PATCH] view,list: fix crash when viewing incomplete imap messages

Robin Jarry <robin@jarry.cc>
Details
Message ID
<20211028144021.1688872-1-robin@jarry.cc>
In-Reply-To
<CELLSBG5K43U.1XB1MGUBKRO4V@dizzy> (view parent)
DKIM signature
missing
Download raw message
Patch: +7 -48
With IMAP, due to an unidentified reason, some messages to not have any
body accessible. When viewing them, aerc crashes:

  git.sr.ht/~sircmpwn/aerc/lib.usePGP
          lib/messageview.go:37
  git.sr.ht/~sircmpwn/aerc/lib.NewMessageStoreView
          lib/messageview.go:67
  git.sr.ht/~sircmpwn/aerc/commands/account.ViewMessage.Execute
          commands/account/view.go:45
  git.sr.ht/~sircmpwn/aerc/commands.(*Commands).ExecuteCommand
          commands/commands.go:66
  main.execCommand
          aerc.go:61
  main.main.func2
          aerc.go:160
  aerc crashed: runtime error: invalid memory address or nil pointer
  dereference

Check the pointer before dereferencing.

Also, add a global check in ParseMessageFormat where a similar issue may
occur.

Signed-off-by: Robin Jarry <robin@jarry.cc>
---
 lib/format/format.go | 52 ++++----------------------------------------
 lib/messageview.go   |  3 +++
 2 files changed, 7 insertions(+), 48 deletions(-)

diff --git a/lib/format/format.go b/lib/format/format.go
index 16398865c8d6..4ee62acaea9c 100644
--- a/lib/format/format.go
+++ b/lib/format/format.go
@@ -58,6 +58,10 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
	}

	envelope := ctx.MsgInfo.Envelope
	if envelope == nil {
		return "", nil,
			errors.New("no envelope available for this message")
	}

	var c rune
	for i, ni := 0, 0; i < len(format); {
@@ -105,10 +109,6 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
		case '%':
			retval = append(retval, '%')
		case 'a':
			if envelope == nil {
				return "", nil,
					errors.New("no envelope available for this message")
			}
			if len(envelope.From) == 0 {
				return "", nil,
					errors.New("found no address for sender")
@@ -117,10 +117,6 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
			retval = append(retval, 's')
			args = append(args, addr.Address)
		case 'A':
			if envelope == nil {
				return "", nil,
					errors.New("no envelope available for this message")
			}
			var addr *mail.Address
			if len(envelope.ReplyTo) == 0 {
				if len(envelope.From) == 0 {
@@ -156,10 +152,6 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
				dummyIfZeroDate(date.Local(),
					timeFmt, thisDayTimeFmt, thisYearTimeFmt))
		case 'f':
			if envelope == nil {
				return "", nil,
					errors.New("no envelope available for this message")
			}
			if len(envelope.From) == 0 {
				return "", nil,
					errors.New("found no address for sender")
@@ -168,10 +160,6 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
			retval = append(retval, 's')
			args = append(args, addr)
		case 'F':
			if envelope == nil {
				return "", nil,
					errors.New("no envelope available for this message")
			}
			if len(envelope.From) == 0 {
				return "", nil,
					errors.New("found no address for sender")
@@ -196,17 +184,9 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
			args = append(args, strings.Join(ctx.MsgInfo.Labels, ", "))

		case 'i':
			if envelope == nil {
				return "", nil,
					errors.New("no envelope available for this message")
			}
			retval = append(retval, 's')
			args = append(args, envelope.MessageId)
		case 'n':
			if envelope == nil {
				return "", nil,
					errors.New("no envelope available for this message")
			}
			if len(envelope.From) == 0 {
				return "", nil,
					errors.New("found no address for sender")
@@ -221,33 +201,17 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
			retval = append(retval, 's')
			args = append(args, val)
		case 'r':
			if envelope == nil {
				return "", nil,
					errors.New("no envelope available for this message")
			}
			addrs := FormatAddresses(envelope.To)
			retval = append(retval, 's')
			args = append(args, addrs)
		case 'R':
			if envelope == nil {
				return "", nil,
					errors.New("no envelope available for this message")
			}
			addrs := FormatAddresses(envelope.Cc)
			retval = append(retval, 's')
			args = append(args, addrs)
		case 's':
			if envelope == nil {
				return "", nil,
					errors.New("no envelope available for this message")
			}
			retval = append(retval, 's')
			args = append(args, envelope.Subject)
		case 't':
			if envelope == nil {
				return "", nil,
					errors.New("no envelope available for this message")
			}
			if len(envelope.To) == 0 {
				return "", nil,
					errors.New("found no address for recipient")
@@ -259,10 +223,6 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
			retval = append(retval, 's')
			args = append(args, ctx.AccountName)
		case 'u':
			if envelope == nil {
				return "", nil,
					errors.New("no envelope available for this message")
			}
			if len(envelope.From) == 0 {
				return "", nil,
					errors.New("found no address for sender")
@@ -275,10 +235,6 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
			retval = append(retval, 's')
			args = append(args, mailbox)
		case 'v':
			if envelope == nil {
				return "", nil,
					errors.New("no envelope available for this message")
			}
			if len(envelope.From) == 0 {
				return "", nil,
					errors.New("found no address for sender")
diff --git a/lib/messageview.go b/lib/messageview.go
index 08ea92fb8bbe..4f1d0cde1db2 100644
--- a/lib/messageview.go
+++ b/lib/messageview.go
@@ -34,6 +34,9 @@ type MessageView interface {
}

func usePGP(info *models.BodyStructure) bool {
	if info == nil {
		return false
	}
	if info.MIMEType == "application" {
		if info.MIMESubType == "pgp-encrypted" ||
			info.MIMESubType == "pgp-signature" {
-- 
2.30.2
Reply to thread Export thread (mbox)