-
Notifications
You must be signed in to change notification settings - Fork 5
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
Windows that are renamed get left to die in the connection.windows table #13
Comments
And another one: Running naim 0.12.0-2011-09-10-0413 (development snapshot) for 7d 20:45m. |
And another one: Assertion failed: strlen(h->addch.buf) == h->addch.len, file hwprintf.c, line 49 Running naim 0.12.0-2011-09-10-0413 (development snapshot) for 21:33m. |
I spy, with my little eye, something beginning with "U". I think it's a use-after-free, with an object left around with Lua references to it after the actual bwin was dead. Here's some telling evidence: Program received signal SIGSEGV, Segmentation fault. |
I have two running hypotheses. I suspect that if a user AWAYs and then DELWINs (i.e., is autoremoved from the winlist) in the same postselect cycle, then there may be a use-after-free condition, but I can't see how that could happen right now. I'm also seeing some pointer strangeness -- in particular: but I need to dive into the Lua code tomorrow to see why I'm getting 0x...70 in the backtrace and 0x...60 in the Lua internal memory dump. |
I have ruled out both hypotheses as root causes. The first hypothesis has been ruled out because the user in question is still online, and the window is still open. The second hypothesis has been ruled out as optimization -- namely, bwin->nwin is the only value used from then on, and: (gdb) up My new hypothesis has to do with the fact that screen names are not canonicalized on insert, but always compared on lookup. When a user changes the case of their name, signs off, and signs back on, then it might be possible that they have two entries in the Lua list of windows, which can result in a use-after-free case as the wrong entry is looked up in the user list. |
I went with the "store by handle" solution. Should also evaluate doing that more generally. About five hours of debugging and tracking came down to 19 insertions(+), 12 deletions(-). |
The following sequence will cause a crash:
After the rename, the user will still be in naim.connections[].windows as "SomeUser", and on the disconnect, they will not be removed from n.c.w. When they connect, the new buddywin_t will be added as "someuser" to n.c.w, but when they rename back to SomeUser, their buddywin's light userdata will be pointing to a dead buddywin_t.
Simply changing delwin() to do a case insensitive remove is not a solution, because on IRC, a user can change their nick to be something else entirely. Proposed solutions are to add a "changewin" function to the C->Lua API, or to change the .windows structure to key on the light userdata itself, and have the lookups be against get_winname; I'm leaning towards the latter.
The original segv for this is as follows:
Running naim 0.12.0-2011-09-10-0413 (development snapshot) for 3d 3:31m.
Segmentation Fault; partial symbolic backtrace:
0: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'naim_faulthandler+0x26 [0x8082fbe]
1: /lib/libc.so.1'__sighndlr+0x15 [0xfee7f495]
2: /lib/libc.so.1'call_user_handler+0x2a2 [0xfee7235e]
3: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'nw_getcol+0xf [0x808746b]
4: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'vhwprintf+0x21 [0x8082061]
5: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'hwprintf+0x18 [0x80820f8]
6: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'window_echof+0x8b [0x807386f]
7: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'_nlua_buddywin_t_echo+0x46 [0x809e1ba]
8: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'luaD_precall+0x216 [0x80aa47a]
9: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'luaV_execute+0xe3a [0x80a95e2]
10: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'luaD_call+0x7b [0x80aa7bf]
11: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'f_call+0x16 [0x80a6b16]
12: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'luaD_rawrunprotected+0x58 [0x80a9d30]
13: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'luaD_pcall+0x3d [0x80aaa6d]
14: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'lua_pcall+0x56 [0x80a6b72]
15: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'_call_hook+0x9c [0x80b0054]
16: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'_nlua_hook+0x72 [0x80b046e]
17: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'main+0x75c [0x8083820]
18: /storage/home/joshua/naim-0.12.0-2011-09-10-0413/src/naim'_start+0x83 [0x8064077]
The text was updated successfully, but these errors were encountered: