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

Roster assertion failure kills profanity with SIGABRT #1083

Closed
ccxcz opened this issue May 2, 2019 · 10 comments · Fixed by #1109
Closed

Roster assertion failure kills profanity with SIGABRT #1083

ccxcz opened this issue May 2, 2019 · 10 comments · Fixed by #1109
Assignees
Labels
Milestone

Comments

@ccxcz
Copy link

ccxcz commented May 2, 2019

Built profanity from commit 722cb5f

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007f65eb48fff0 in __GI_abort () at abort.c:79
#2  0x00007f65eb4864ea in __assert_fail_base (fmt=0x7f65eb5ebf18 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55e4f9083994 "roster != NULL",     
    file=file@entry=0x55e4f908397d "src/xmpp/roster_list.c", line=line@entry=158, function=function@entry=0x55e4f9083c20 <__PRETTY_FUNCTION__.12916> "roster_get_contact")   
    at assert.c:92
#3  0x00007f65eb48656a in __GI___assert_fail (assertion=assertion@entry=0x55e4f9083994 "roster != NULL", file=file@entry=0x55e4f908397d "src/xmpp/roster_list.c",            
    line=line@entry=158, function=function@entry=0x55e4f9083c20 <__PRETTY_FUNCTION__.12916> "roster_get_contact") at assert.c:101                                            
#4  0x000055e4f8fdd4b5 in roster_get_contact (barejid=<optimized out>) at src/xmpp/roster_list.c:158                                                                         
#5  roster_get_contact (barejid=<optimized out>) at src/xmpp/roster_list.c:156
#6  0x000055e4f8ff9860 in _display_name (tab=<optimized out>, tab=<optimized out>) at src/ui/statusbar.c:523                                                                 
#7  0x000055e4f8ff9ff3 in _tabs_width () at src/ui/statusbar.c:481
#8  status_bar_draw () at src/ui/statusbar.c:265
#9  0x000055e4f8ff658d in ui_update () at src/ui/core.c:140
#10 0x000055e4f8fdaa94 in prof_run (log_level=<optimized out>, account_name=<optimized out>) at src/profanity.c:129                                                          
#11 0x000055e4f8fd71df in main (argc=<optimized out>, argv=<optimized out>) at src/main.c:170                                                                                

This happens randomly with no activity from user by just being connected to several active MUCs.

@jubalh jubalh added the bug label May 2, 2019
@jubalh jubalh added this to the 0.7.0 milestone May 2, 2019
@ccxcz
Copy link
Author

ccxcz commented May 2, 2019

Custom theme that I run Profanity with can be found at: https://gist.github.com/ccxcz/100c5fbbadba6ecaba2feb6f1c0f7465

@pasis
Copy link
Member

pasis commented May 2, 2019

Looks like this is use after free issue. Roster is freed on connection loss and ui_update() tries to read it.

@jubalh
Copy link
Member

jubalh commented May 6, 2019

Didnt check the ui_update(). Did some related chagnes however. @ccxcz maybe you can test with latest master (9ecc14c) and see if this still happens there. And then give feedback here?

@ccxcz
Copy link
Author

ccxcz commented May 14, 2019

I've tested with c94f3d0 and the problem I get now is that on reconnect the rooms now don't get rejoined properly and if I try to join a room manually I get a crash that seems to indicate it tries to switch to the window without checking it exists:

49      abort.c: No such file or directory.
(gdb) bt  
#0  __GI_abort () at abort.c:49                                     
#1  0x00007fd2ce6064ea in __assert_fail_base (fmt=0x7fd2ce76bf18 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x559d1fe3e67a "window != NULL",
    file=file@entry=0x559d1fe3e5e3 "src/ui/core.c", line=line@entry=647, function=function@entry=0x559d1fe3ebd8 <__PRETTY_FUNCTION__.25017> "ui_focus_win") at assert.c:92
#2  0x00007fd2ce60656a in __GI___assert_fail (assertion=0x559d1fe3e67a "window != NULL", file=0x559d1fe3e5e3 "src/ui/core.c", line=647,
    function=0x559d1fe3ebd8 <__PRETTY_FUNCTION__.25017> "ui_focus_win") at assert.c:101                                                                                      
#3  0x0000559d1fd94518 in ui_focus_win (window=0x0) at src/ui/core.c:647               
#4  0x0000559d1fd94a77 in ui_switch_to_room (roomjid=0x559d54cb6b60 "<redacted>@conference.blesmrt.net") at src/ui/core.c:808
#5  0x0000559d1fdb8468 in cmd_join (window=0x559d216d6640, command=0x559d5417f7e0 "/join", args=0x559d222ef350) at src/command/cmd_funcs.c:3634
#6  0x0000559d1fdc3a2a in _cmd_execute (window=0x559d216d6640, command=0x559d5417f7e0 "/join", inp=0x559d6c790970 "/join <redacted>@conference.blesmrt.net")
    at src/command/cmd_funcs.c:7857
#7  0x0000559d1fdaf0f0 in cmd_process_input (window=0x559d216d6640, inp=0x559d6c790970 "/join <redacted>@conference.blesmrt.net") at src/command/cmd_funcs.c:139
#8  0x0000559d1fd6e2a7 in prof_run (log_level=0x559d1fe5f3d0 "INFO", account_name=0x0) at src/profanity.c:115                                                                
#9  0x0000559d1fdf9d13 in main (argc=1, argv=0x7ffc2dd37268) at src/main.c:170

--

#3  0x0000559d1fd94518 in ui_focus_win (window=0x0) at src/ui/core.c:647
647         assert(window != NULL);
(gdb) i
642     }
643
644     void                              
645     ui_focus_win(ProfWin *window)
646     {                                                                                                                                  
647         assert(window != NULL);
648
649         if (wins_is_current(window)) {                                                                                                 
650             return;
651         }                                                                                                                                                                
#3  0x0000559d1fd94518 in ui_focus_win (window=0x0) at src/ui/core.c:647
647         assert(window != NULL);                                                   
window = 0x0                                                    
__PRETTY_FUNCTION__ = "ui_focus_win"                                                   
old_current = 0x0                                                 
i = 21917                                                                                
identifier = 0x0                                                            

--

#4  0x0000559d1fd94a77 in ui_switch_to_room (roomjid=0x559d54cb6b60 "<redacted>@conference.blesmrt.net") at src/ui/core.c:808                                             
808         ui_focus_win(window);                                             
(gdb) i                                                                                                                                                                      
803                      
804     void
805     ui_switch_to_room(const char *const roomjid)                                                                                                                    
806     {                                                                                                                                                                 
807         ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
808         ui_focus_win(window);
809     }                                                                                                                              
810                                                                                    
811     void       
812     ui_room_destroy(const char *const roomjid)
#4  0x0000559d1fd94a77 in ui_switch_to_room (roomjid=0x559d54cb6b60 "<redacted>@conference.blesmrt.net") at src/ui/core.c:808
808         ui_focus_win(window);  
roomjid = 0x559d54cb6b60 "<redacted>@conference.blesmrt.net"
window = 0x0

--

#5  0x0000559d1fdb8468 in cmd_join (window=0x559d216d6640, command=0x559d5417f7e0 "/join", args=0x559d222ef350) at src/command/cmd_funcs.c:3634
3634            ui_switch_to_room(room);                                                                                                                                     
(gdb) i                                                                                                                                                                      
3629               
3630        if (!muc_active(room)) {                            
3631            presence_join_room(room, nick, passwd);
3632            muc_join(room, nick, passwd, FALSE);
3633        } else if (muc_roster_complete(room)) {
3634            ui_switch_to_room(room);                            
3635        }                                                                                                                                                           
3636                                                                                                                                                                      
3637        jid_destroy(room_arg);                                                                                                     
3638        account_free(account);                                                                                                                                           
#5  0x0000559d1fdb8468 in cmd_join (window=0x559d216d6640, command=0x559d5417f7e0 "/join", args=0x559d222ef350) at src/command/cmd_funcs.c:3634
3634            ui_switch_to_room(room);                                                                                        
window = 0x559d216d6640                                                                                                                        
command = 0x559d5417f7e0 "/join"                                                                                                                               
args = 0x559d222ef350              
conn_status = JABBER_CONNECTED                                                                                                                                     
room_arg = 0x559d222e91f0                                                                                                                                                    
room = 0x559d54cb6b60 "<redacted>@conference.blesmrt.net"                  
nick = 0x559d222ef740 "ccx"                                                                                                                                                  
passwd = 0x0             
account_name = 0x559d21ddf440 "ccx@blesmrt.net"
account = 0x559d6387cf90                                                                                                                                                
opt_keys = {0x559d1fe5246d "nick", 0x559d1fe52452 "password", 0x0}                                                                                                        
parsed = 1                                                    
options = 0x559d5ee80a40         

@ccxcz
Copy link
Author

ccxcz commented May 14, 2019

From usability perspective I find closing the windows on connection drop rather inconvenient, especially if they are to be rejoined after reconnect. It means all the conversations get purged on every network hiccup. Sure, I still get logs (if I enable them), but it definitely worsens usability of running Profanity in the background and then coming back to read the backlog.

jubalh added a commit that referenced this issue May 27, 2019
Call `ui_close_all_wins();` only if we disconnect on purpose not when
connection is lost.

Otherwise users might miss messages.

This partly reverts 6ac73db.
Regards #1083
@pasis
Copy link
Member

pasis commented Jun 3, 2019

To reproduce this bug, change preferences:

/statusbar show name
/statusbar hide number

and cause a connection loss (autoping or broken connection). After the connection loss roster is destroyed, but it is accessed during rewriting UI to calculate width for statusbar.

To solve this we must not take window's name from the roster. Rather save it in the window object.

@jubalh
Copy link
Member

jubalh commented Jun 3, 2019

With 48013f8 I changed the statusbar setting. Closed my Laptops lid, opened it after a while and got this:
Error from profanity@rooms.dismail.de/jubalh: You must join the room before sending presence updates
No crash though. But I guess we need to fix this to check if we joined already/rejoin MUCs when we regain connection.

@jubalh jubalh self-assigned this Jun 4, 2019
jubalh added a commit that referenced this issue Jun 4, 2019
Save the name for displaying the windows in the statusbar inside the tab
object.
So far we calculated them repeatedly and this created issues when we
lost the connection.

Regards #1083
jubalh added a commit that referenced this issue Jun 4, 2019
We destory the roster in ev_disconnect_cleanup().
Adding a function to test if the roster has been destroyed and testing
for it in the statusbar.

So now when the connection is lost 'Lost connection' is printed in all
open windows.
We can then reconnect with `/connect accountname`.

Should fix #1083
@jubalh
Copy link
Member

jubalh commented Jun 4, 2019

@ccxcz can you please test the new PR?

jubalh added a commit that referenced this issue Jun 4, 2019
We destory the roster in ev_disconnect_cleanup().
Adding a function to test if the roster has been destroyed and testing
for it in the statusbar.

So now when the connection is lost 'Lost connection' is printed in all
open windows.
We can then reconnect with `/connect accountname`.

Should fix #1083
@jubalh jubalh reopened this Jun 5, 2019
@jubalh
Copy link
Member

jubalh commented Jun 5, 2019

Some people tested the PR and said it worked. However I'll leave this open for @ccxcz to reply.

@ccxcz
Copy link
Author

ccxcz commented Jun 7, 2019

The crashes are gone indeed. There is ongoing problem with MUCs not getting reconnected properly, but that's deserving of it's own issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants