Project

General

Profile

Actions

Bug #3

open

Capabilities detection causes crash when starting Fernschreiber X

Added by xet7 about 4 years ago. Updated about 4 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Start date:
01/14/2020
Due date:
% Done:

0%

Estimated time:

Description

When using Debian sid, compiling, and then starting Fernschreiber X, I get error:

2020/01/14 11:51:22 <iq xml:lang='fi' to='xet7@guelker.eu/fernschreiberx' from='xet7@guelker.eu' type='result' id='47690vkkbrwzu33060221239'><query xmlns='jabber:iq:roster'><item subscription='both' jid='mg@guelker.eu'/><item subscription='both' jid='sydney@sydev.us'/><item ask='subscribe' jid='sydney@kode.im'/></query></iq>
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xa24c16]

goroutine 1 [running]:
main.(*CapsEntry).HasFeature(0x0, 0xbe6ebd, 0x12, 0x5)
    /home/user/go/src/mg.guelker.eu/fernschreiberx/fernschreiberx/caps_cache.go:182 +0x26
main.(*Application).onFeaturesList.func1.1(0xaee700, 0xc000264a40)
    /home/user/go/src/mg.guelker.eu/fernschreiberx/fernschreiberx/application.go:357 +0x142
main.(*Application).onIQStanza(0xc0000ee9c0)
    /home/user/go/src/mg.guelker.eu/fernschreiberx/fernschreiberx/application.go:644 +0xe2a
main.NewApplication.func11()
    /home/user/go/src/mg.guelker.eu/fernschreiberx/fernschreiberx/application.go:76 +0x2a
reflect.Value.call(0xab7d00, 0xc000021e30, 0x13, 0xbe1685, 0x4, 0x13ec1e8, 0x0, 0x0, 0xc000170ac8, 0x4af0ac, ...)
    /usr/lib/go-1.13/src/reflect/value.go:460 +0x5f6
reflect.Value.Call(0xab7d00, 0xc000021e30, 0x13, 0x13ec1e8, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/lib/go-1.13/src/reflect/value.go:321 +0xb4
github.com/gotk3/gotk3/glib.goMarshal(0x1e23dc0, 0x2343a80, 0xc000000001, 0x229eed0, 0x7ffc778182d0, 0x0)
    /home/user/go/src/github.com/gotk3/gotk3/glib/glib.go:233 +0x700
github.com/gotk3/gotk3/glib._cgoexpwrap_25d77dd69e85_goMarshal(0x1e23dc0, 0x2343a80, 0xa00000001, 0x229eed0, 0x7ffc778182d0, 0x0)
    _cgo_gotypes.go:4413 +0x5b
github.com/gotk3/gotk3/glib._Cfunc_g_signal_emitv(0x229eed0, 0x18, 0x2343a80)
    _cgo_gotypes.go:3058 +0x45
github.com/gotk3/gotk3/glib.(*Object).Emit(0xc0000105e0, 0xbe5466, 0xe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/user/go/src/github.com/gotk3/gotk3/glib/glib.go:818 +0x486
main.emitXMPPSignal(0xbe5466, 0xe)
    /home/user/go/src/mg.guelker.eu/fernschreiberx/fernschreiberx/transformer.go:94 +0x58
reflect.Value.call(0xac0040, 0xc01d10, 0x13, 0xbe1685, 0x4, 0xc0002d7840, 0x1, 0x1, 0x98, 0x4af0ac, ...)
    /usr/lib/go-1.13/src/reflect/value.go:460 +0x5f6
reflect.Value.Call(0xac0040, 0xc01d10, 0x13, 0xc0002d7840, 0x1, 0x1, 0xc0002d4ef0, 0x98, 0x0)
    /usr/lib/go-1.13/src/reflect/value.go:321 +0xb4
github.com/gotk3/gotk3/glib.goMarshal(0x7f11800058d0, 0x7ffc77818600, 0xc000000000, 0x0, 0x0, 0x0)
    /home/user/go/src/github.com/gotk3/gotk3/glib/glib.go:233 +0x700
github.com/gotk3/gotk3/glib._cgoexpwrap_25d77dd69e85_goMarshal(0x7f11800058d0, 0x7ffc77818600, 0x0, 0x0, 0x0, 0x0)
    _cgo_gotypes.go:4413 +0x5b
github.com/gotk3/gotk3/gtk._Cfunc_gtk_main()
    _cgo_gotypes.go:14719 +0x41
github.com/gotk3/gotk3/gtk.Main(...)
    /home/user/go/src/github.com/gotk3/gotk3/gtk/gtk.go:987
main.(*Application).onActivate(0xc0000ee9c0)
    /home/user/go/src/mg.guelker.eu/fernschreiberx/fernschreiberx/application.go:228 +0x1c9
main.NewApplication.func2()
    /home/user/go/src/mg.guelker.eu/fernschreiberx/fernschreiberx/application.go:66 +0x2a
reflect.Value.call(0xab7d00, 0xc000021d10, 0x13, 0xbe1685, 0x4, 0x13ec1e8, 0x0, 0x0, 0xc0000bba18, 0x4af0ac, ...)
    /usr/lib/go-1.13/src/reflect/value.go:460 +0x5f6
reflect.Value.Call(0xab7d00, 0xc000021d10, 0x13, 0x13ec1e8, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/lib/go-1.13/src/reflect/value.go:321 +0xb4
github.com/gotk3/gotk3/glib.goMarshal(0x1e22be0, 0x0, 0x1, 0x7ffc77818ac0, 0x7ffc77818a40, 0x0)
    /home/user/go/src/github.com/gotk3/gotk3/glib/glib.go:233 +0x700
github.com/gotk3/gotk3/glib._cgoexpwrap_25d77dd69e85_goMarshal(0x1e22be0, 0x0, 0x1, 0x7ffc77818ac0, 0x7ffc77818a40, 0x0)
    _cgo_gotypes.go:4413 +0x5b
github.com/gotk3/gotk3/glib._Cfunc_g_application_run(0x1e1f0f0, 0x1, 0x1e20880, 0x0)
    _cgo_gotypes.go:1236 +0x4d
github.com/gotk3/gotk3/glib.(*Application).Run.func4(0xc000093b90, 0xc0000201b0, 0x1, 0x1, 0x1e20880, 0xc0000105e0)
    /home/user/go/src/github.com/gotk3/gotk3/glib/application.go:202 +0xa6
github.com/gotk3/gotk3/glib.(*Application).Run(0xc000093b90, 0xc0000201b0, 0x1, 0x1, 0x0)
    /home/user/go/src/github.com/gotk3/gotk3/glib/application.go:202 +0x181
main.(*Application).Run(...)
    /home/user/go/src/mg.guelker.eu/fernschreiberx/fernschreiberx/application.go:106
main.main()
    /home/user/go/src/mg.guelker.eu/fernschreiberx/fernschreiberx/main.go:40 +0x86

But if I comment out this code:

diff --git a/fernschreiberx/caps_cache.go b/fernschreiberx/caps_cache.go
index 322e233..9e00315 100644
--- a/fernschreiberx/caps_cache.go
+++ b/fernschreiberx/caps_cache.go
@@ -179,11 +179,11 @@ func (recv *CapabilitiesCache) Load() error {
 // which needs to be a URI. Returns true if the feature is found,
 // false otherwise.
 func (recv *CapsEntry) HasFeature(feature string) bool {
-       for _, f := range recv.Features {
-               if f == feature {
-                       return true
-               }
-       }
+       //for _, f := range recv.Features {
+       //      if f == feature {
+       //              return true
+       //      }
+       //}

        return false
 }

Then I can start Fernschreiber X successfully.

Actions #1

Updated by quintus about 4 years ago

This is strange. The crash seems to be caused by a NULL pointer
dereference, i.e. *recv is nil, while it should be an instance of
CapabilitiesCache. I have not worked with Fernschreiber X's code since a
long time, so I can't make further comments at the moment.

The capabilities cache is an integral part of modern XMPP clients (it is
described in XEP-0115). Making HasFeature() always return false
means that the client will assume that your chat partners and your XMPP
server run ancient XMPP software. Consequently, things like message
carbons (for multi-device chats) or server-side archiving will not work,
nor will any other feature which is described in a XEP. That is, with
that modification, you end up with a bare RFC 6120/6121 client.

-quintus

Actions #2

Updated by xet7 about 4 years ago

Should that code check that it is not nil ?

Or what would be proper fix ?

Actions #3

Updated by quintus about 4 years ago

Or what would be proper fix ?

The proper fix would be to find out why *recv is nil and ensure that this is not an accident -- it most likely is. Maybe the parser has a bug. If the nil value is an accident, the bug causing *recv to be nil has to be fixed. Only if you're certain that the nil value is not an accident, checking for the nil case would be correct.

Actions #4

Updated by xet7 about 4 years ago

This patch also makes it possible to start Fernscreiber X, so it does not crash:

diff --git a/fernschreiberx/application.go b/fernschreiberx/application.go
index 8b66bec..50f4141 100644
--- a/fernschreiberx/application.go
+++ b/fernschreiberx/application.go
@@ -354,14 +354,14 @@ func (recv *Application) onFeaturesList() {
                                        } // else TODO: Server does not send XEP-0115, §6.3 <c/> feature. Query directly

                                        // Request message carbons
-                                       if (recv.serverCaps.HasFeature("urn:xmpp:carbons:2")) {
+                                       //if (recv.serverCaps.HasFeature("urn:xmpp:carbons:2")) {
                                                recv.MainWindow.GlobalSystemMessage(T("Requesting message carbons"))
                                                iq = fernx.IQCarbonsEnable()
                                                iq.From = recv.clientJID
                                                var cds fernx.CarbonsEnableSet
                                                iq.Payload = &cds
                                                recv.conn.SendStanza(iq) // Do not care for the result; either the carbons come or they don't
-                                       }
+                                       //}
                                }
                        }
                case "http://jabber.org/protocol/caps": // XEP-0115, §6.3 server caps advertisement

Actions

Also available in: Atom PDF