profanity-im / profanity

Ncurses based XMPP client
https://profanity-im.github.io/
Other
1.3k stars 181 forks source link

Crash on inbound message in new conversation. #397

Closed Rtzq0 closed 10 years ago

Rtzq0 commented 10 years ago

I'm having a problem where profanity 0.4.3 crashes after (or maybe immediately before?) receiving an inbound message from a user whom I have not spoken with in that session.

If I /msg user and then the user sends a message, no issue If I /msg user and then /close window and the user sends a message, no issue If I do not /msg user and user sends a message, profanity crashes.

Here's some debug logs. I'm going to try and do some testing tonight. Please note that profanity crashes immediately at the end of the log.

13/08/2014 16:25:35: prof: DBG: Available presence handler fired for foo@gmail.com/C070663C
13/08/2014 16:25:35: prof: DBG: Presence contains capabilities.
13/08/2014 16:25:35: prof: DBG: Hash type sha-1 supported.
13/08/2014 16:25:35: prof: DBG: Node string: http://pidgin.im/#lV6i//bt2U8Rm0REcX8h4F3Nk3M=.
13/08/2014 16:25:35: prof: DBG: Capabilities not cached for 'foo@gmail.com/C070663C', sending discovery IQ.
13/08/2014 16:25:35: conn: DBG: SENT: <iq id="prof_caps_9" to="foo@gmail.com/C070663C" type="get"><query xmlns="http://jabber.org/protocol/disco#info
 " node="http://pidgin.im/#lV6i//bt2U8Rm0REcX8h4F3Nk3M="/></iq>
13/08/2014 16:25:36: xmpp: DBG: RECV: <iq id="prof_caps_8" to="jasonritzke@4loopz.com/profanity" type="result" from="foo@gmail.com/C070663C"><query x
 mlns="http://jabber.org/protocol/disco#info" node="http://pidgin.im/#lV6i//bt2U8Rm0REcX8h4F3Nk3M="><identity category="client" type="pc" name="Pidgin"/><f
 eature var="jabber:iq:last"/><feature var="jabber:iq:oob"/><feature var="urn:xmpp:time"/><feature var="jabber:iq:version"/><feature var="jabber:x:conferen
 ce"/><feature var="http://jabber.org/protocol/bytestreams"/><feature var="http://jabber.org/protocol/caps"/><feature var="http://jabber.org/protocol/chats
 tates"/><feature var="http://jabber.org/protocol/disco#info"/><feature var="http://jabber.org/protocol/disco#items"/><feature var="http://jabber.org/proto
 col/muc"/><feature var="http://jabber.org/protocol/muc#user"/><feature var="http://jabber.org/protocol/si"/><feature var="http://jabber.org/protocol/si/pr
 ofile/file-transfer"/><feature var="http://jabber.org/protocol/xhtml-im"/><feature var="urn:xmpp:ping"/><feature var="urn:xmpp:attention:0"/><feature var=
 "urn:xmpp:bob"/><feature var="urn:xmpp:jingle:1"/><feature var="http://www.google.com/xmpp/protocol/session"/><feature var="http://www.google.com/xmpp/pro
 tocol/voice/v1"/><feature var="http://www.google.com/xmpp/protocol/video/v1"/><feature var="http://www.google.com/xmpp/protocol/camera/v1"/><feature var="
 urn:xmpp:jingle:apps:rtp:1"/><feature var="urn:xmpp:jingle:apps:rtp:audio"/><feature var="urn:xmpp:jingle:apps:rtp:video"/><feature var="urn:xmpp:jingle:t
 ransports:raw-udp:1"/><feature var="urn:xmpp:jingle:transports:ice-udp:1"/><feature var="urn:xmpp:avatar:metadata+notify"/><feature var="http://jabber.org
 /protocol/mood+notify"/><feature var="http://jabber.org/protocol/tune+notify"/><feature var="http://jabber.org/protocol/nick+notify"/><feature var="http:/
 /jabber.org/protocol/ibb"/></query></iq>
13/08/2014 16:25:36: prof: DBG: Recieved diso#info response
13/08/2014 16:25:36: xmpp: DBG: RECV: <iq id="prof_caps_9" to="jasonritzke@4loopz.com/profanity" type="result" from="foo@gmail.com/C070663C"><query x
 mlns="http://jabber.org/protocol/disco#info" node="http://pidgin.im/#lV6i//bt2U8Rm0REcX8h4F3Nk3M="><identity category="client" type="pc" name="Pidgin"/><f
 eature var="jabber:iq:last"/><feature var="jabber:iq:oob"/><feature var="urn:xmpp:time"/><feature var="jabber:iq:version"/><feature var="jabber:x:conferen
 ce"/><feature var="http://jabber.org/protocol/bytestreams"/><feature var="http://jabber.org/protocol/caps"/><feature var="http://jabber.org/protocol/chats
 tates"/><feature var="http://jabber.org/protocol/disco#info"/><feature var="http://jabber.org/protocol/disco#items"/><feature var="http://jabber.org/proto
 col/muc"/><feature var="http://jabber.org/protocol/muc#user"/><feature var="http://jabber.org/protocol/si"/><feature var="http://jabber.org/protocol/si/pr
 ofile/file-transfer"/><feature var="http://jabber.org/protocol/xhtml-im"/><feature var="urn:xmpp:ping"/><feature var="urn:xmpp:attention:0"/><feature var=
 "urn:xmpp:bob"/><feature var="urn:xmpp:jingle:1"/><feature var="http://www.google.com/xmpp/protocol/session"/><feature var="http://www.google.com/xmpp/pro
 tocol/voice/v1"/><feature var="http://www.google.com/xmpp/protocol/video/v1"/><feature var="http://www.google.com/xmpp/protocol/camera/v1"/><feature var="
 urn:xmpp:jingle:apps:rtp:1"/><feature var="urn:xmpp:jingle:apps:rtp:audio"/><feature var="urn:xmpp:jingle:apps:rtp:video"/><feature var="urn:xmpp:jingle:t
 ransports:raw-udp:1"/><feature var="urn:xmpp:jingle:transports:ice-udp:1"/><feature var="urn:xmpp:avatar:metadata+notify"/><feature var="http://jabber.org
 /protocol/mood+notify"/><feature var="http://jabber.org/protocol/tune+notify"/><feature var="http://jabber.org/protocol/nick+notify"/><feature var="http:/
 /jabber.org/protocol/ibb"/></query></iq>
13/08/2014 16:25:36: prof: DBG: Recieved diso#info response
13/08/2014 16:25:40: xmpp: DBG: RECV: <message id="purplec48cf58c" to="jasonritzke@4loopz.com" type="chat" from="foo@gmail.com/C070663C"><composing x
 mlns="http://jabber.org/protocol/chatstates"/><x xmlns="google:nosave" value="disabled"/><record xmlns="http://jabber.org/protocol/archive" otr="false"/><
 /message>
boothj5 commented 10 years ago

I think the issue was when the contact is not in your roster and chat states are enabled. Should be fixed now in master, if you have a chance to test it out, let me know your findings.

Thanks.

Rtzq0 commented 10 years ago

Hey!

I think I'm getting differing results on different machines. Library problem? I'll be able to test the one that is working (at home) more fully when I get home. At work right now, so testing on this one.

Both are running arch, and built from 9fd4505. With logging set to DEBUG, this is the last thing I see before the segfault, a composing notification:

21/08/2014 13:21:46: xmpp: DBG: RECV: <message id="purpled89d7cc1" to="jasonritzke@4loopz.com" type="chat" from="blarg@honk.org/1ce025198b8e4077"><composing xmlns
 ="http://jabber.org/protocol/chatstates"/></message>

I know you said that this has to do with the contact not being in my roster but all of the contacts that this is happening for are definitely in my roster, and I see them as online before they send the message.

EDIT: In case this matters...

openssl-1.0.1.i-1 curl-7.37.1-1 expat-2.1.0-3 libxss-1.2.2-2 libnotify-0.7.6-1 libotr-4.0.0-5 libstrophe-1:0.8.6-1

boothj5 commented 10 years ago

I spotted something strange in the logging, the element has no closing ">" before the nested element starts, although the original logging you sent appears to be valid.

Is this a pasting error? If not it would definitely be causing a problem, although there are still a few possibilities:

1) Your contact's client is sending a malformed stanza 2) Your server is sending a malformed stanza. 3) Libstrophe is reading data incorrectly.

If it's not a pasting error, my guess is 3. I did see a similar(ish) issue a while ago that has now been fixed in libstrophe https://github.com/strophe/libstrophe/pull/21 it might be worth rebuilding and installing libstrophe from latest source just to check this isn't the problem, if you have time.

boothj5 commented 10 years ago

Just seen your edit, looks like you have the latest libstrophe. Let me know if the pasting is correct.

Rtzq0 commented 10 years ago

It was a pasting issue, apologies. I have edited my post.

Is there a way to dump incoming stanzas so we can look at them? I know Psi and Pidgin have an XMPP console.

My server is Prosody 0.9.4, if it makes a difference.

boothj5 commented 10 years ago

No problem.

The logging is essentially dumping the stanzas as received before attempting to parse them. The /xmlconsole command will also log them in a window, but they'll be the same.

Sounds perhaps like its a bug in the chat states code, perhaps with a certain combination of configuration options. If you can attach your ~/.config/profanity/profrc from the machine with the issue, I'll try to recreate.

boothj5 commented 10 years ago

Also, if you are able to, a backtrace would help isolate the code segfaulting:

http://www.profanity.im/issues.html#backtrace

But no problem if you don't have time.

Rtzq0 commented 10 years ago
[notifications]
message=true
remind=5
typing=true
invite=true
sub=true

[ui]
theme=headache

history=false

splash=true

[otr]
policy=manual

[connection]
account=4loopz

[logging]
chlog=false

EDIT: working on a backtrace now

Rtzq0 commented 10 years ago

Build error attempting to build with configure-debug:

configure.ac:11: installing 'build-aux/compile'
configure.ac:14: installing 'build-aux/config.guess'
configure.ac:14: installing 'build-aux/config.sub'
configure.ac:8: installing 'build-aux/install-sh'
configure.ac:8: installing 'build-aux/missing'
Makefile.am: installing 'build-aux/depcomp'
parallel-tests: installing 'build-aux/test-driver'
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for main in -lstrophe... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for ncursesw... yes
checking for wget_wch support in ncursesw... yes
checking for glib... yes
checking for curl... yes                                                                                                                                          [50/266]
checking for libnotify... yes
checking for main in -lXss... yes
checking for main in -lX11... yes
checking for library containing otrl_init... -lotr
checking for cmocka... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking ncursesw/ncurses.h usability... no
checking ncursesw/ncurses.h presence... no
checking for ncursesw/ncurses.h... no
checking ncurses.h usability... yes
checking ncurses.h presence... yes
checking for ncurses.h... yes
checking for atexit... yes
checking for memset... yes
checking for strdup... yes
checking for strstr... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/config.h
config.status: executing depfiles commands

PLATFORM       : linux-gnu
PACKAGE_STATUS : development
AM_CFLAGS      : -Wall -Wno-deprecated-declarations -Wunused -Werror
AM_CPPFLAGS    :   -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -pthread -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib
/glib-2.0/include  -DTHEMES_PATH="\"${pkgdatadir}/themes\""
LIBS           : -lotr -lX11 -lXss -lstrophe  -lncursesw  -lglib-2.0  -lcurl  -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
Install themes : true
Themes path    : ${pkgdatadir}/themes

Now you can run `make' to build profanity
test -z "profanity" || rm -f profanity
test -z "tests/testsuite" || rm -f tests/testsuite
rm -f src/gitversion.h src/gitversion.h.in
rm -f *.o
rm -f src/*.o
rm -f src/command/*.o
rm -f src/config/*.o
rm -f src/otr/*.o
rm -f src/tools/*.o
rm -f src/ui/*.o
rm -f src/xmpp/*.o
rm -f tests/*.o
rm -f tests/config/*.o
rm -f tests/log/*.o
rm -f tests/otr/*.o
rm -f tests/ui/*.o
rm -f tests/xmpp/*.o
test -z "tests/testsuite.log" || rm -f tests/testsuite.log
test -z "tests/testsuite.trs" || rm -f tests/testsuite.trs
test -z "test-suite.log" || rm -f test-suite.log
rm -f src/gitversion.h.in
echo "#ifndef PROF_GIT_BRANCH" >> src/gitversion.h.in
echo "#define PROF_GIT_BRANCH \"makepkg\"" >> src/gitversion.h.in
echo "#endif" >> src/gitversion.h.in
echo "#ifndef PROF_GIT_REVISION" >> src/gitversion.h.in
echo "#define PROF_GIT_REVISION \"9fd4505\"" >> src/gitversion.h.in
echo "#endif" >> src/gitversion.h.in
cp src/gitversion.h.in src/gitversion.h
make  all-am
make[1]: Entering directory '/home/ritzke/Custom_Pkgs/profanity-git/src/profanity'
depbase=`echo src/contact.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -DHAVE_CONFIG_H -I. -I./src  -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -pthread -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-
2.0 -I/usr/lib/glib-2.0/include  -DTHEMES_PATH="\"/usr/local/share/profanity/themes\"" -D_FORTIFY_SOURCE=2 -Wall -Wno-deprecated-declarations -Wunused -Werror -g3 -O0 -MT
 src/contact.o -MD -MP -MF $depbase.Tpo -c -o src/contact.o src/contact.c &&\
mv -f $depbase.Tpo $depbase.Po
In file included from /usr/include/assert.h:35:0,
                 from src/contact.c:23:
/usr/include/features.h:341:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
    ^
cc1: all warnings being treated as errors
Makefile:1156: recipe for target 'src/contact.o' failed
make[1]: *** [src/contact.o] Error 1
make[1]: Leaving directory '/home/ritzke/Custom_Pkgs/profanity-git/src/profanity'
Makefile:741: recipe for target 'all' failed
make: *** [all] Error 2

Can I safely make -O ?

EDIT: Sorry, that's a dumb question, I mean run gcc with -O on

boothj5 commented 10 years ago

I've not seen this before, but the good news is, I recreated from your config, and have a backtrace to work from now.

Thanks for the info.

I'll keep this issue up to date with progress on fixing it.

boothj5 commented 10 years ago

The problem should be fixed now in master, it was bug in some newer functionality to disable typing notifications for the current window.

If you can try out master (./configure rather than ./configure-debug until the build issue is resolved), let me know your findings.

Thanks.

Rtzq0 commented 10 years ago

This appears fixed for me on 0b47bba .

boothj5 commented 10 years ago

Great, thanks for your help.

Please reopen the issue if the problem occurs again.