topaz-next / topaz

💎 A server emulator for Final Fantasy XI.
GNU General Public License v3.0
55 stars 81 forks source link

Server Crash (expected number, received nil) [Canary a7a0283] #2652

Closed kaincenteno closed 3 years ago

kaincenteno commented 3 years ago

Additional Information (Steps to reproduce/Expected behavior) :

I am trying to reach out to the player to see what was their last action

[19/Feb] [12:53:20] [Info] parse: 061 | 00BD 00BC 04 from user: Kryptkeeper
[19/Feb] [12:53:21] [Warning] CLuaBaseEntity::trySkillUp() - Non-PC passed to function.
[sol3] An error occurred and panic has been invoked: stack index 1, expected number, received nil: not a numeric type
terminate called after throwing an instance of 'sol::error'
  what():  lua: error: stack index 1, expected number, received nil: not a numeric type

Thread 1 "topaz_game" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
--Type <RET> for more, q to quit, c to continue without paging--

45      in ../sysdeps/unix/sysv/linux/raise.c
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7df4859 in __GI_abort () at abort.c:79
#2  0x00007ffff7b14951 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff7b2047c in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff7b204e7 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff7b20799 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x000055555557d864 in sol::default_at_panic (L=0x40020378) at /usr/include/c++/9/ext/new_allocator.h:89
#7  0x00007ffff7c6cee0 in ?? () from /usr/lib/x86_64-linux-gnu/libluajit-5.1.so.2
#8  0x00007ffff7c81d56 in ?? () from /usr/lib/x86_64-linux-gnu/libluajit-5.1.so.2
#9  0x00007ffff7c81e2d in lua_error () from /usr/lib/x86_64-linux-gnu/libluajit-5.1.so.2
#10 0x00005555556611b1 in sol::type_panic_c_str (message=0x5555557e67fb "not a numeric type", actual=<optimized out>, expected=sol::type::number, index=1, L=<optimized out>)
    at /topaz-next/ext/sol/include/sol/sol.hpp:8638
#11 sol::stack::unqualified_checker<signed char, (sol::type)3, void>::check<int (&)(lua_State*, int, sol::type, sol::type, char const*)> (handler=<optimized out>, tracking=<synthetic pointer>..., 
    index=1, L=<optimized out>) at /topaz-next/ext/sol/include/sol/sol.hpp:11280
#12 sol::stack::unqualified_check<int, int (&)(lua_State*, int, sol::type, sol::type, char const*)> (tracking=<synthetic pointer>..., handler=<optimized out>, index=1, L=<optimized out>)
    at /topaz-next/ext/sol/include/sol/sol.hpp:10708
#13 sol::stack::qualified_checker<int, (sol::type)3, void>::check<int (&)(lua_State*, int, sol::type, sol::type, char const*)> (tracking=<synthetic pointer>..., handler=<optimized out>, index=1, 
    L=<optimized out>) at /topaz-next/ext/sol/include/sol/sol.hpp:11812
#14 sol::stack::check<int, int (&)(lua_State*, int, sol::type, sol::type, char const*)> (tracking=<synthetic pointer>..., handler=<optimized out>, index=1, L=<optimized out>)
    at /topaz-next/ext/sol/include/sol/sol.hpp:10734
#15 sol::stack::check<int, int (&)(lua_State*, int, sol::type, sol::type, char const*)> (handler=<optimized out>, index=1, L=<optimized out>) at /topaz-next/ext/sol/include/sol/sol.hpp:10741
#16 sol::stack::qualified_check_getter<int, void>::get<int (&)(lua_State*, int, sol::type, sol::type, char const*)> (handler=<optimized out>, tracking=<synthetic pointer>..., index=1, L=<optimized out>)
    at /topaz-next/ext/sol/include/sol/sol.hpp:13367
#17 sol::stack::check_get<int, int (&)(lua_State*, int, sol::type, sol::type, char const*)> (tracking=..., handler=<optimized out>, index=<optimized out>, L=<optimized out>, L=<optimized out>, 
    index=<optimized out>, handler=<optimized out>, tracking=...) at /topaz-next/ext/sol/include/sol/sol.hpp:10812
#18 sol::stack::get<int> (tracking=..., index=<optimized out>, L=<optimized out>, L=<optimized out>, index=<optimized out>, tracking=...) at /topaz-next/ext/sol/include/sol/sol.hpp:10901
#19 sol::stack::get<int> (index=<optimized out>, L=<optimized out>, L=<optimized out>, index=<optimized out>) at /topaz-next/ext/sol/include/sol/sol.hpp:10912
#20 sol::protected_function_result::get<int> (this=<optimized out>, index_offset=<optimized out>) at /topaz-next/ext/sol/include/sol/sol.hpp:15845
#21 0x0000555555752892 in luautils::OnMobWeaponSkill (action=0x7fffffffd700, PMobSkill=0x55558ba282f0, PMob=<optimized out>, PTarget=<optimized out>)
    at /topaz-next/ext/sol/include/sol/sol.hpp:9525
#22 CMobEntity::OnMobSkillFinished (this=0x55556c630740, state=..., action=...) at /topaz-next/src/map/entities/mobentity.cpp:697
#23 0x00005555555d84a0 in CMobSkillState::Update (this=0x55558ba7f300, tick=...) at /topaz-next/src/map/ai/states/mobskill_state.cpp:98
#24 0x000055555576c78d in CState::DoUpdate (tick=..., this=0x55558ba7f300) at /topaz-next/src/map/ai/states/state.cpp:88
#25 CAIContainer::Tick (this=0x55556c631480, _tick=...) at /topaz-next/src/map/ai/ai_container.cpp:379
#26 0x0000555555776d9f in CZoneEntities::ZoneServer (this=0x555557391040, tick=..., check_regions=false) at /usr/include/c++/9/bits/unique_ptr.h:360
#27 0x000055555576fb0f in CZone::ZoneServer (this=0x5555572b3a10, tick=..., check_regions=<optimized out>) at /topaz-next/src/map/zone.cpp:804
#28 0x000055555577471b in zone_server (tick=..., PTask=<optimized out>) at /usr/include/c++/9/any:556
#29 0x00005555555b743f in CTaskMgr::DoTimer (tick=..., this=0x555555a0e4a0) at /usr/include/c++/9/chrono:557
#30 main (argc=<optimized out>, argv=<optimized out>) at /topaz-next/src/common/kernel.cpp:275
   0x7ffff7e15185 <__GI_raise+197>:     (bad)  
   0x7ffff7e15186 <__GI_raise+198>:     add    %al,(%rax)
   0x7ffff7e15188 <__GI_raise+200>:     add    %cl,(%rdi)
   0x7ffff7e1518a <__GI_raise+202>:     add    $0x24848b48,%eax
   0x7ffff7e1518f <__GI_raise+207>:     or     %al,(%rcx)
ghost commented 3 years ago

@kaincenteno Are you sure your code and build is up to date? That warning was removed a decent amount of time ago.

kaincenteno commented 3 years ago

@claywar reproduceable in Canary 385ac9a. The ability "Mmurk" that crashed it was NM in Promyvion Mea Promathia Mission

ghost commented 3 years ago

My guess is that core doesn't like the possible nil return from that script (we're doing a get on the result without checking). Can you try declaring local typeEffect=0 in the script and seeing if that temporarily resolves the issue for that skill?

TeoTwawki commented 3 years ago

https://github.com/topaz-next/topaz/blob/83e1840708afdd491ceeb66547103478f66dd289/scripts/globals/mobskills/murk.lua ?

But you actually don't want to return zero, because that is actually a valid effect ID (death, in fact, even though we never use it in dsp/tpz). We should probably just define it as WEIGHT first and then let that if check do slow if slow landed. misread the else's there

Edit: Returning nil shouldn't be a problem really. So that will need fixed if that's the case we have a ton of things that return a nil in similar circumstances. Does need a local declaration before getting to those conditionals though.

ghost commented 3 years ago

We definitely need to fix this on the core side. I just don't have the bandwidth at the moment fix that function. By design, the function in luautils would return 0 if the return result wasn't valid (though its broken).

ghost commented 3 years ago

Crashing on return result.return_count() ? result.get<int32>() : 0; Since result.get<int32>(nil) isn't making things happy. -- Note this is what I'm assuming

TeoTwawki commented 3 years ago

I like (not) how autocorrect tries to reverse the meaning of things I say all the time (does > doesn't)...

zach2good commented 3 years ago

All instanced of return_count() -> get<>() are replaced with get_type() == sol::type::_ ? get<>(), meaning it'll handle nil's coming back from Lua safely: https://github.com/topaz-next/topaz/commit/0ffae5aaa89cb8533c2c0439c18800e53dd87ba0