Southclaws / pawn-chrono

A modern Pawn library for working with dates and times.
MIT License
18 stars 6 forks source link

wtf linux server crash #1

Closed TommyB123 closed 6 years ago

TommyB123 commented 6 years ago

me code

new year, month, day, age;
cache_get_value_name_int(0, "BirthYear", year);
cache_get_value_name_int(0, "BirthMonth", month);
cache_get_value_name_int(0, "BirthDate", day);

new Timestamp:seconds, Seconds:agetime;
TimeParse(sprintf("%i%i%i", year, month, day), "%Y%m%d", seconds);
agetime = Now() - seconds;

backtrace

[06/15/2018 14:45:01] Server crashed while executing RCRP_MySQL.amx
[06/15/2018 14:45:01] AMX backtrace:
[06/15/2018 14:45:01] #0 native TimeParse () from chrono.so
[06/15/2018 14:45:01] #1 003a3f1c in GetPlayerAge (playerid=1) at C:\Users\TommyB\Desktop\servers\redcountyrp\gamemodes\RCRP_MySQL.pwn:48360
[06/15/2018 14:45:01] #2 00301c20 in public SelectStatsForPlayer (ofplayerid=1, forplayerid=1) at C:\Users\TommyB\Desktop\servers\redcountyrp\gamemodes\RCRP_MySQL.pwn:38295
[06/15/2018 14:45:01] Native backtrace:
[06/15/2018 14:45:01] #0 f7bb9180 in _Z13GetStackTraceRSt6vectorI10StackFrameSaIS0_EEPv () from plugins/crashdetect.so
[06/15/2018 14:45:01] #1 f7bb1064 in _ZN11CrashDetect20PrintNativeBacktraceERSoRKN2os7ContextE () from plugins/crashdetect.so
[06/15/2018 14:45:01] #2 f7bb1d64 in _ZN11CrashDetect20PrintNativeBacktraceERKN2os7ContextE () from plugins/crashdetect.so
[06/15/2018 14:45:01] #3 f7bb3cdb in _ZN11CrashDetect7OnCrashERKN2os7ContextE () from plugins/crashdetect.so
[06/15/2018 14:45:01] #4 f7bb84d5 in ?? () from plugins/crashdetect.so
[06/15/2018 14:45:01] #5 f7f29340 in ?? ()
[06/15/2018 14:45:01] #6 f7f29319 in ?? ()
[06/15/2018 14:45:01] #7 f7c11137 in gsignal () from /lib/libc.so.6
[06/15/2018 14:45:01] #8 f7c12973 in abort () from /lib/libc.so.6
[06/15/2018 14:45:01] #9 f7e5790d in _ZN9__gnu_cxx27__verbose_terminate_handlerEv () from /lib/libstdc++.so.6
[06/15/2018 14:45:01] #10 f7e553d3 in ?? () from /lib/libstdc++.so.6
[06/15/2018 14:45:01] #11 f7e5540f in ?? () from /lib/libstdc++.so.6
[06/15/2018 14:45:01] #12 f7e55678 in ?? () from /lib/libstdc++.so.6
[06/15/2018 14:45:01] #13 f7eafa72 in ?? () from /lib/libstdc++.so.6
[06/15/2018 14:45:01] #14 f4c6a807 in _ZSt9use_facetINSt7__cxx118time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEEEERKT_RKSt6locale () from plugins/chrono.so
[06/15/2018 14:45:01] #15 f4c1490a in ?? () from plugins/chrono.so
[06/15/2018 14:45:01] #16 0809d844 in ?? () from ./devsvr
[06/15/2018 14:45:01] #17 f7bb2ad3 in _ZN11CrashDetect17HandleAMXCallbackEiPiS0_ () from plugins/crashdetect.so
[06/15/2018 14:45:01] Registers:
[06/15/2018 14:45:01] EAX: 00000000 EBX: 00001175 ECX: 00001175 EDX: 00000006
[06/15/2018 14:45:01] ESI: 081aed6c EDI: f7da9000 EBP: 2cae5868 ESP: ff9eaa84
[06/15/2018 14:45:01] EIP: f7f29319 EFLAGS: 00200282
[06/15/2018 14:45:01] Stack:
[06/15/2018 14:45:01] ESP+00000000: 2cae5868 00000006 00001175 f7c11137
[06/15/2018 14:45:01] ESP+00000020: ff9eaab4 00000000 f7e10a9c ff9eab18
[06/15/2018 14:45:01] ESP+00000040: 00000000 00000000 00000000 00000000
[06/15/2018 14:45:01] ESP+00000060: 00000000 00000000 00000000 00000000
[06/15/2018 14:45:01] ESP+00000080: 00000000 00000000 00000000 00000000
[06/15/2018 14:45:01] ESP+000000a0: 00000000 00000000 00000000 00000000
[06/15/2018 14:45:01] ESP+000000c0: f7be12b0 f7f24ad0 f7dc8b40 00000001
[06/15/2018 14:45:01] ESP+000000e0: f7f3965d f7f24ad0 f7dc8be0 00000001
[06/15/2018 14:45:01] ESP+00000100: 00000005 00000001 f7ec0e7e 2cae5868
[06/15/2018 14:45:01] ESP+00000120: f7eef000 081aed6c f7ec0e7e 2cae5868
[06/15/2018 14:45:01] ESP+00000140: 081aed6c f7ec0e7e f7e5790d 0000000a
[06/15/2018 14:45:01] ESP+00000160: f7f3965d 00000000 11440200 00000001
[06/15/2018 14:45:01] ESP+00000180: f7eebc44 ff9eb038 f7e553d3 00000000
[06/15/2018 14:45:01] ESP+000001a0: f7e553c6 f7eef000 f7e5540f f7e57770
[06/15/2018 14:45:01] ESP+000001c0: f7e553f6 f7eef000 f7e55678 2cae5018
[06/15/2018 14:45:01] ESP+000001e0: f4cf0000 ff9eaff4 f7eafa72 2cae5038
[06/15/2018 14:45:01] ESP+00000200: f7eafa36 f4cf0000 f4c6a807 f7ef6154
[06/15/2018 14:45:01] ESP+00000220: ff9eb220 00000001 f7c5b1e5 00000003
[06/15/2018 14:45:01] ESP+00000240: 00000020 00000005 f7c5b1e5 00001fe4
[06/15/2018 14:45:01] ESP+00000260: 2cb87aa8 00001fe4 11440200 76654c20
[06/15/2018 14:45:01] ESP+00000280: f7da9420 00000006 2cb87aa0 2cb87aa8
[06/15/2018 14:45:01] ESP+000002a0: f7da9420 00000040 00000001 2c953910
[06/15/2018 14:45:01] ESP+000002c0: 00000000 ff9ead68 f785cafd f785cae9
[06/15/2018 14:45:01] ESP+000002e0: 00000000 ff9ead88 f785cafd 00000000
[06/15/2018 14:45:01] ESP+00000300: f7873ade ff9eadb8 f782739e f7826139
[06/15/2018 14:45:01] ESP+00000320: 000003e8 0002db51 f7b9a000 0002db51
[06/15/2018 14:45:01] ESP+00000340: ff9eb020 000003e8 00000000 23ea9c68
[06/15/2018 14:45:01] ESP+00000360: 2ca61970 00000020 ff9eaf84 00000000
[06/15/2018 14:45:01] ESP+00000380: 2c9538e8 f4cf0000 0000000c f785cae9
[06/15/2018 14:45:01] ESP+000003a0: 2cd54c74 ff9eae01 f785cafd 00000000
[06/15/2018 14:45:01] ESP+000003c0: f7ae7000 ff9eae68 f7826a45 2cb87aa0
[06/15/2018 14:45:01] ESP+000003e0: 00001001 ff9eaef8 f7827e47 2cb87aa0
[06/15/2018 14:45:01] Loaded modules:
[06/15/2018 14:45:01] 00000000 - 00194f0b devsvr
[06/15/2018 14:45:01] f7f28000 - f7f29596 
[06/15/2018 14:45:01] f7f12000 - f7f146ec /lib/libdl.so.2
[06/15/2018 14:45:01] f7ef7000 - f7f10ceb /lib/libpthread.so.0
[06/15/2018 14:45:01] f7e0b000 - f7efcf48 /lib/libstdc++.so.6
[06/15/2018 14:45:01] f7dc9000 - f7e0a178 /lib/libm.so.6
[06/15/2018 14:45:01] f7dad000 - f7dc66f8 /lib/libgcc_s.so.1
[06/15/2018 14:45:01] f7be2000 - f7db3fdb /lib/libc.so.6
[06/15/2018 14:45:01] f7f2a000 - f7f4d15c /lib/ld-linux.so.2
[06/15/2018 14:45:01] f7b9b000 - f7bddac4 plugins/crashdetect.so
[06/15/2018 14:45:01] f7b33000 - f7b9b788 plugins/mysql.so
[06/15/2018 14:45:01] f7b05000 - f7b31b58 /home/ucpdev/RC-RPDev/plugins/../log-core.so
[06/15/2018 14:45:01] f7f1a000 - f7f20da8 /lib/librt.so.1
[06/15/2018 14:45:01] f7811000 - f7afdf38 /home/ucpdev/RC-RPDev/plugins/libmysqlclient.so.18
[06/15/2018 14:45:01] f77fa000 - f780ee10 /lib/libz.so.1
[06/15/2018 14:45:01] f7791000 - f77fb0e4 /lib/libssl.so.10
[06/15/2018 14:45:01] f75a7000 - f77a7614 /lib/libcrypto.so.10
[06/15/2018 14:45:01] f755c000 - f75a6c10 /lib/libgssapi_krb5.so.2
[06/15/2018 14:45:01] f7486000 - f756314c /lib/libkrb5.so.3
[06/15/2018 14:45:01] f7481000 - f748373d /lib/libcom_err.so.2
[06/15/2018 14:45:01] f744c000 - f747f6dc /lib/libk5crypto.so.3
[06/15/2018 14:45:01] f7433000 - f744ac4c /lib/libresolv.so.2
[06/15/2018 14:45:01] f7424000 - f7430a94 /lib/libkrb5support.so.0
[06/15/2018 14:45:01] f741f000 - f7421c38 /lib/libkeyutils.so.1
[06/15/2018 14:45:01] f73f8000 - f741dea0 /lib/libselinux.so.1
[06/15/2018 14:45:01] f7393000 - f73f6584 /lib/libpcre.so.1
[06/15/2018 14:45:01] f5f6d000 - f61febb6 plugins/bcrypt-samp.so
[06/15/2018 14:45:01] f5d8d000 - f5f7864d plugins/streamer.so
[06/15/2018 14:45:01] f634c000 - f635b40c plugins/sscanf.so
[06/15/2018 14:45:01] f7af8000 - f7b02f81 plugins/fixes2.so
[06/15/2018 14:45:01] f6344000 - f6349892 plugins/filemanager.so
[06/15/2018 14:45:01] f633b000 - f6342500 plugins/memory.so
[06/15/2018 14:45:01] f5950000 - f5a5e79b plugins/ColAndreas.so
[06/15/2018 14:45:01] f4cf3000 - f4d58cc2 plugins/bitmapper.so
[06/15/2018 14:45:01] f54d6000 - f54f697c plugins/log-plugin.so
[06/15/2018 14:45:01] f4bab000 - f4cf45b9 plugins/chrono.so
TommyB123 commented 6 years ago

Southclaws - Today at 4:27 PM can you drop a comment on the issue any comment

Southclaws commented 6 years ago

Okay so you're formatting year month day into one long number, if the data was 1997-03-12 then that format call would result in 19970312 which just looks like one fat integer, 19,970,312. This won't work with any time parser so you should add some separators, probably - characters.

As for the crash, I've not reproduced it yet but I would assume it's from here. If I can get it to reproduce I'll add a proper try/catch around the parser code so it at least doesn't crash on invalid input like this!

Southclaws commented 6 years ago

I can't seem to reproduce the crash on Linux or Windows, is there any chance you know the exact numbers that went into the format call?

Found the crash line, just for reference, 6021 in date.h:

        auto& f = use_facet<time_get<CharT>>(is.getloc());
Southclaws commented 6 years ago

Try these:

plugins.zip

TommyB123 commented 6 years ago

all is well thanks mr. southclaw