Closed michaelortmann closed 3 years ago
Added fix for crash in core/userrec.c:welcome_suser() if no language selected
Doesn't make much sense anyway, because without a language selected the mod may behave bad, like it would send "NOLANG" to a user instead of any meaningful text.
Before:
.load stats
[21:57:22] tcl: builtin dcc call: *dcc:loadmod -HQ 1 stats
[21:57:22] mem: memtbl size doubled to 8192.
[21:57:21] Creating nopubstats (type 1)
[21:57:21] Creating quietstats (type 1)
[21:57:21] Creating nostats (type 1)
[21:57:21] Stats.mod v1.5.0 loaded.
[21:57:21] Module loaded: stats
[21:57:21] #-HQ# loadmod stats
Module loaded: stats
[21:57:35] New user peak in #test6888: 1.
[21:57:35] BotA joined #test6888.
[21:58:00] Channel '#test6888' desynched: 2 eggmembers vs 1 statsmembers. Resynching...
[21:58:00] Stats.Mod: Created suserrec for testuser.
[22:00:00] Writing user file...
[22:00:00] Writing channel file...
[22:03:00] Stats.Mod: Added BotA(*!?BotA@localhost) to userbase.
[22:03:00] WARNING! No language selected! (getslang())
[22:03:00] * Last context: stats:userrec.c/169 []
[22:03:00] * Please REPORT this BUG!
[22:03:00] * Check doc/BUG-REPORT on how to do so.
[22:03:00] * Wrote DEBUG
[22:03:00] * SEGMENT VIOLATION -- CRASHING!
Segmentation fault (core dumped)
(gdb) bt
#0 0x00007fa34d6b45c0 in slang_multitext_get_next () at ./core/slang_multitext.c:145
#1 0x00007fa34d6b460a in slang_id_get_next () at ./core/slang_ids.c:104
#2 0x00007fa34d6b463c in getslang_next () at ./core/slang.c:328
#3 0x00007fa34d6b4711 in welcome_suser (nick=0x555aee3b9890 "BotA", u=0x555aee3bc820,
chan=0x555aee3b50a0 "#test6888") at ./core/userrec.c:286
#4 0x00007fa34d6ba8b8 in stats_autosadd (m=0x555aee3b9580, chan=0x555aee3b2ae0) at ./core/userrec.c:259
#5 0x00007fa34d6baa3a in sensor_minutely () at ./core/sensors.c:228
#6 0x00007fa34d6bab3a in sensor_minutely () at ./core/sensors.c:255
#7 0x00007fa34d6c0941 in write_stats () at ./core/datahandling.c:471
#8 0x0000555aedc41035 in core_secondly () at ./main.c:656
#9 0x0000555aedc41e52 in mainloop (toplevel=toplevel@entry=1) at ./main.c:830
#10 0x0000555aedc4304d in main (arg_c=3, arg_v=<optimized out>) at ./main.c:1299
After:
.load stats
[23:56:57] tcl: builtin dcc call: *dcc:loadmod -HQ 1 stats
[23:56:57] mem: memtbl size doubled to 8192.
[23:56:56] ERROR reading stats file
[23:56:56] Creating nopubstats (type 1)
[23:56:56] Creating quietstats (type 1)
[23:56:56] Creating nostats (type 1)
[23:56:56] Stats.mod v1.5.0 loaded.
[23:56:56] Module loaded: stats
[23:56:56] #-HQ# loadmod stats
Module loaded: stats
[23:57:09] New user peak in #test6888: 1.
[23:57:09] BotA joined #test6888.
[23:58:00] Channel '#test6888' desynched: 2 eggmembers vs 1 statsmembers. Resynching...
[23:58:00] Stats.Mod: Created suserrec for testuser.
[00:00:00] --- Thu Dec 17 2020
[00:00:00] Backing up user file...
[00:00:00] Backing up channel file...
[00:00:00] Writing user file...
[00:00:00] Writing channel file...
[00:03:00] Stats.Mod: Added BotA(*!?BotA@localhost) to userbase.
[00:03:00] Stats warning: no language selected. (getslang_first())
[00:03:00] -BotA (~BotA@localhost)- NOLANG
Thanks a lot for your contribution!
I think it's all right that it only works on 1.8+. People can use one of the older releases for older eggdrop versions.
I have no means to test it further myself though, so I just merged it and hope that the bugs that you feared are either not there, insignificant, or will be fixed by someone else. :)
stats.mod doesnt build with eggdrop 1.8-rc1+ due to changed module API (function
answer()
) with eggdrop commit https://github.com/eggheads/eggdrop/commit/12cff4496d1bac1b3f6876a54590dc5c522de7ad. This PR fixes compilation with eggdrop 1.8.Developer test against eggdrop git https://github.com/eggheads/eggdrop/tree/f59fb68811437536ee86dedb1ca23a31b48a5cca (20201206):
It loads, but it is not further tested yet and thus probably still buggy for eggdrop 1.8, esp. the changed http-part.
Due to the changed module API, versions of stats.mod before this PR will only work until eggdrop 1.8-rc1 and versions of stats mod with/after this PR will only work from eggdrop 1.8-rc1. Choose your poison ;) I guess its possible to ifdef code, so that it would work for all versions, but this i leave for someone else to do, should there be interest.