Connection issues on private server.

Discussion about topics that don't fit elsewhere.
mikaelh
Developer
Posts: 190
Joined: Sun Dec 13, 2009 3:18 pm

Re: Connection issues on private server.

Post by mikaelh » Wed Sep 19, 2018 9:11 pm

I simply turned on address sanitizer. After that it was quite obvious what was happening.

Scanned 2 objects. Removed 1.
18 Sep (Tue) 00:33:48 EVENT_TIMEOUT: 5 - Arena Monster Challenge.
18 Sep (Tue) 00:33:48 EVENT_END: 5 - 'Arena Monster Challenge'.
18 Sep (Tue) 00:33:48 EVENT_NOPLAYERS: 11 (Highlander Tournament) has only 0/2 participants.
18 Sep (Tue) 00:33:48 EVENT_END: 11 - 'Highlander Tournament'.
QUESTITEM_D: t22,s30,p0 is already zero.
Scanned 1 objects. Removed 1.
18 Sep (Tue) 01:00:07_CRON1H_1:0:7
18 Sep (Tue) 01:00:07 EVENT_CREATE: #4 of type 5 parms='>'
=================================================================
==8413==ERROR: AddressSanitizer: attempting double-free on 0x61600005cd80 in thread T0:
#0 0x7fb87d764750 in __interceptor_free /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/asan/asan_malloc_linux.cc:66
#1 0x7fb87d0a6ef4 in fclose (/lib64/libc.so.6+0x72ef4)
#2 0x7fb87d762a10 in __interceptor_fclose /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:5558
#3 0x55ad14b88bed in my_fclose server/util.c:374
#4 0x55ad14e9dc19 in export_player_store_offers server/store.c:7694
#5 0x55ad14f55153 in dungeon server/dungeon.c:8100
#6 0x55ad14ed758b in sched server/sched.c:270
#7 0x55ad14f34ba8 in play_game server/dungeon.c:8817
#8 0x55ad14b5b963 in main server/main.c:420
#9 0x7fb87d0584ca in __libc_start_main (/lib64/libc.so.6+0x244ca)
#10 0x55ad14b5c839 in _start (/home/mikaelh/tomenet/release/testing/tomenet-4.7.1a/tomenet.server+0x13c839)

0x61600005cd80 is located 0 bytes inside of 552-byte region [0x61600005cd80,0x61600005cfa8)
freed by thread T0 here:
==8413==AddressSanitizer CHECK failed: /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/asan/asan_descriptions.cc:176 "((res.trace)) != (0)" (0x0, 0x0)
#0 0x7fb87d770082 in AsanCheckFailed /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/asan/asan_rtl.cc:67
#1 0x7fb87d78c439 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/sanitizer_common/sanitizer_termination.cc:77
#2 0x7fb87d6a42fc in GetStackTraceFromId /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/asan/asan_descriptions.cc:176
#3 0x7fb87d6a5869 in __asan::HeapAddressDescription::Print() const /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/asan/asan_descriptions.cc:427
#4 0x7fb87d6a5ecc in __asan::ErrorDoubleFree::Print() /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/asan/asan_errors.cc:60
#5 0x7fb87d76cd4b in __asan::ErrorDescription::Print() /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/asan/asan_errors.h:338
#6 0x7fb87d76cd4b in __asan::ScopedInErrorReport::~ScopedInErrorReport() /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/asan/asan_report.cc:136
#7 0x7fb87d76cd4b in __asan::ReportDoubleFree(unsigned long, __sanitizer::BufferedStackTrace*) /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/asan/asan_report.cc:212
#8 0x7fb87d6a34b4 in __asan::Allocator::ReportInvalidFree(void*, unsigned char, __sanitizer::BufferedStackTrace*) /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/asan/asan_allocator.cc:650
#9 0x7fb87d6a34b4 in __asan::Allocator::AtomicallySetQuarantineFlagIfAllocated(__asan::AsanChunk*, void*, __sanitizer::BufferedStackTrace*) /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/asan/asan_allocator.cc:521
#10 0x7fb87d6a34b4 in __asan::Allocator::Deallocate(void*, unsigned long, __sanitizer::BufferedStackTrace*, __asan::AllocType) /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/asan/asan_allocator.cc:595
#11 0x7fb87d764719 in __interceptor_free /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/asan/asan_malloc_linux.cc:69
#12 0x7fb87d0a6ef4 in fclose (/lib64/libc.so.6+0x72ef4)
#13 0x7fb87d762a10 in __interceptor_fclose /var/tmp/portage/sys-devel/gcc-8.2.0-r2/work/gcc-8.2.0/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:5558
#14 0x55ad14b88bed in my_fclose server/util.c:374
#15 0x55ad14e9dc19 in export_player_store_offers server/store.c:7694
#16 0x55ad14f55153 in dungeon server/dungeon.c:8100
#17 0x55ad14ed758b in sched server/sched.c:270
#18 0x55ad14f34ba8 in play_game server/dungeon.c:8817
#19 0x55ad14b5b963 in main server/main.c:420
#20 0x7fb87d0584ca in __libc_start_main (/lib64/libc.so.6+0x244ca)
#21 0x55ad14b5c839 in _start (/home/mikaelh/tomenet/release/testing/tomenet-4.7.1a/tomenet.server+0x13c839)

C. Blue
Developer
Posts: 329
Joined: Sun Dec 13, 2009 6:28 pm

Re: Connection issues on private server.

Post by C. Blue » Fri Sep 21, 2018 12:32 pm

Please search the file src/server/store.c for "o_list export completed". You should find three occurances of this string.
Go to the first one. The next line after this should say "(*export_turns) = 0;". Now again after this line please insert 3 new lines:

coverage = 0;
coverage_trad = FALSE;
copied = opened = FALSE;

And re-compile the server. The crash should hopefully be fixed now.

r7st
Posts: 9
Joined: Sat Sep 15, 2018 2:23 pm

Re: Connection issues on private server.

Post by r7st » Sat Sep 22, 2018 6:26 pm

mikaelh, Great! I did not know of address sanitizer.
C. Blue, That seemed to fix the issue. Thanks to both of you!

Patch here:

Code: Select all

--- store.c-orig        2018-09-21 17:20:51.514400296 -0400
+++ store.c     2018-09-21 17:22:26.189399361 -0400
@@ -7694,6 +7694,9 @@
                        my_fclose(fp);
                        s_printf("EXPORT_PLAYER_STORE_OFFERS: o_list export completed.\n");
                        (*export_turns) = 0; //don't re-call us again, we're done for this time
+                       coverage = 0;
+                       coverage_trad = FALSE;
+                       copied = opened = FALSE;
                        goto timing_before_return; // HACK - Execute timing code before returning
                        return;
                }

Post Reply