Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault when writing message to self #1308

Closed
mdosch opened this issue Apr 10, 2020 · 9 comments
Closed

Segfault when writing message to self #1308

mdosch opened this issue Apr 10, 2020 · 9 comments
Assignees
Labels
Milestone

Comments

@mdosch
Copy link
Contributor

mdosch commented Apr 10, 2020

When I sent a message to my own JID with conversations profanity crashed with a segfault. @pasis assumed this is to a missing resource part in either from or to. The message I received had bare JID without resource part in "from=".

Expected Behavior

No segfault.

Current Behavior

Segfault

Steps to Reproduce (for bugs)

  1. Send a message to your own JID with conversations
  2. Profanity segfaults

Environment

Debian Bullseye (Testing)
Version 0.8.1dev.master.f42f856d as well as Version 0.8.1dev.master.c90a5d17

(gdb) bt
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
#1  0x00007ffff6c206df in __GI___strdup (s=0x0) at strdup.c:41
#2  0x00005555555b0542 in win_print_history (window=0x55555be1b020, message=0x55555c852040) at src/ui/window.c:1229
#3  0x00005555555c9a63 in _chatwin_history (chatwin=0x55555be1b020, contact_barejid=0x55555ad16720 "martin@mdosch.de")
    at src/ui/chatwin.c:489
#4  0x00005555555c92f5 in chatwin_incoming_msg (chatwin=0x55555be1b020, message=0x55555ad08f40, win_created=1)
    at src/ui/chatwin.c:281
#5  0x00005555555aabf4 in _sv_ev_incoming_omemo (chatwin=0x55555be1b020, new_win=1, message=0x55555ad08f40, logit=0)
    at src/event/server_events.c:595
#6  0x00005555555aaeb5 in sv_ev_incoming_carbon (message=0x55555ad08f40) at src/event/server_events.c:798
#7  0x000055555559c8d3 in _handle_carbons (stanza=0x55555cbbf2a0) at src/xmpp/message.c:1127
#8  0x000055555559c970 in _handle_chat (stanza=0x55555cbbf2a0) at src/xmpp/message.c:1153
#9  0x000055555559a61a in _message_handler (conn=0x555555d1bf00, stanza=0x55555cbbf2a0, userdata=0x555555fc1d70)
    at src/xmpp/message.c:155
#10 0x00007ffff6d64ebf in handler_fire_stanza (conn=conn@entry=0x555555d1bf00, stanza=stanza@entry=0x55555cbbf2a0)
    at src/handler.c:124
#11 0x00007ffff6d61a6b in _handle_stream_stanza (stanza=0x55555cbbf2a0, userdata=0x555555d1bf00) at src/conn.c:1181
#12 0x00007ffff6d6db0f in _end_element (userdata=0x555555fc1c70, name=<optimized out>) at src/parser_expat.c:190
#13 0x00007ffff5bc08aa in doContent (parser=parser@entry=0x555555efad00, startTagLevel=startTagLevel@entry=0, 
    enc=<optimized out>, s=<optimized out>, end=<optimized out>, nextPtr=0x555555efad30, haveMore=1 '\001')
    at ../../src/lib/xmlparse.c:2845
#14 0x00007ffff5bc157c in contentProcessor (parser=0x555555efad00, start=<optimized out>, end=<optimized out>, 
    endPtr=<optimized out>) at ../../src/lib/xmlparse.c:2444
#15 0x00007ffff5bc3b1c in XML_ParseBuffer (isFinal=0, len=<optimized out>, parser=0x555555efad00)
    at ../../src/lib/xmlparse.c:1893
#16 XML_ParseBuffer (parser=0x555555efad00, len=<optimized out>, isFinal=0) at ../../src/lib/xmlparse.c:1863
#17 0x00007ffff6d64794 in xmpp_run_once (ctx=0x555555fc1d70, timeout=10) at src/event.c:263
#18 0x0000555555593573 in connection_check_events () at src/xmpp/connection.c:119
#19 0x0000555555592a7d in session_process_events () at src/xmpp/session.c:256
#20 0x000055555558c249 in prof_run (log_level=0x555555647852 "INFO", account_name=0x0, config_file=0x0, log_file=0x0, 
    heme_name=0x0) at src/profanity.c:129
#21 0x000055555561d636 in main (argc=1, argv=0x7fffffffe1e8) at src/main.c:180
@pasis
Copy link
Member

pasis commented Apr 10, 2020

Must be something wrong with recent sqlite code. Your incoming message can be either PROF_MSG_TYPE_CHAT or PROF_MSG_TYPE_MUCPM according to _handle_carbons(). But it crashes, because message is PROF_MSG_TYPE_MUC.

@jubalh
Copy link
Member

jubalh commented Apr 10, 2020

And how does it get set PROF_MSG_TYPE_MUC if I either make it a PROF_MSG_TYPE_CHAT or PROF_MSG_TYPE_MUCPM?

@jubalh
Copy link
Member

jubalh commented Apr 10, 2020

@mdosch You sent a message from martin@example.org to martin@example.org via regular 1:1 chat from Conversations while both clients were online?

@mdosch
Copy link
Contributor Author

mdosch commented Apr 10, 2020 via email

@jubalh
Copy link
Member

jubalh commented Apr 10, 2020

"forward from a MUC" I wonder what it does there. Whether there is really some kind of forwarding (thus type=muc) or whether it just copies it the content.

@mdosch
Copy link
Contributor Author

mdosch commented Apr 10, 2020 via email

@mdosch
Copy link
Contributor Author

mdosch commented Apr 10, 2020 via email

@jubalh
Copy link
Member

jubalh commented Apr 10, 2020

Problem is the SQL statement

SELECT * FROM (SELECT `message`, `timestamp`, `from_jid`, `type` from `ChatLogs` WHERE `from_jid` = '%s' OR `to_jid` = '%s' ORDER BY `timestamp` DESC LIMIT 10) ORDER BY `timestamp` ASC;

@jubalh jubalh closed this as completed in b2eea96 Apr 10, 2020
@jubalh jubalh self-assigned this Apr 10, 2020
@jubalh jubalh added the bug label Apr 10, 2020
@jubalh jubalh added this to the 0.9.0 milestone Apr 10, 2020
@mdosch
Copy link
Contributor Author

mdosch commented Apr 10, 2020 via email

@jubalh jubalh changed the title Segfault when "from" doesn't contain a resource part Segfault when writing message to self Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants