Raised This Month: $51 Target: $400
 12% 

[EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown


Post New Thread Reply   
 
Thread Tools Display Modes
Electr000999
Senior Member
Join Date: Aug 2011
Old 07-29-2013 , 12:20   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #561

Martijn79, i install your compiled bin, and last gamedata from https://left4downtown2.googlecode.co...ntown.l4d2.txt, and have crash on join people in server
Code:
0xffe35635
1 server_srv.so!SurvivorCheckpointLeaving::Update(SurvivorBot*, float) + 0xb3
2 libstdc++.so.6 + 0x887ac
(
Electr000999 is offline
Send a message via Skype™ to Electr000999
Martijn79
Member
Join Date: Jan 2013
Old 07-29-2013 , 12:28   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #562

Quote:
Originally Posted by Electr000999 View Post
Martijn79, i install your compiled bin, and last gamedata from https://left4downtown2.googlecode.co...ntown.l4d2.txt, and have crash on join people in server
Code:
0xffe35635
1 server_srv.so!SurvivorCheckpointLeaving::Update(SurvivorBot*, float) + 0xb3
2 libstdc++.so.6 + 0x887ac
(
Yes confirmed. It loaded but I didn't join yet to test

You get this error right. Did you already test the latest 1.5.0 SM snapshot? If it doesn't work use the older one for now:

https://forums.alliedmods.net/showpo...&postcount=525

Code:
warning: Can't read pathname for load map: Input/output error.

warning: .dynamic section for "/home/l4duser4/left4dead2/left4dead2/addons/sourcemod/bin/sourcemod_mm_i486.so" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/home/l4duser4/left4dead2/left4dead2/addons/sourcemod/bin/sourcemod.2.l4d2.so" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/home/l4duser4/left4dead2/left4dead2/addons/sourcemod/bin/sourcemod.logic.so" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/home/l4duser4/left4dead2/left4dead2/addons/sourcemod/extensions/l4d2_bugfixes.ext.so" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/home/l4duser4/left4dead2/left4dead2/addons/sourcemod/extensions/left4downtown.ext.2.l4d2.so" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/home/l4duser4/left4dead2/left4dead2/addons/sourcemod/extensions/prhelpers.ext.so" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/home/l4duser4/left4dead2/left4dead2/addons/sourcemod/extensions/clientprefs.ext.so" is not at the expected address (wrong library or version mismatch?)

warning: .dynamic section for "/home/l4duser4/left4dead2/left4dead2/addons/sourcemod/extensions/regex.ext.so" is not at the expected address (wrong library or version mismatch?)
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./srcds_linux -game left4dead2 -gdb=/usr/bin/gdb -debug'.
Program terminated with signal 6, Aborted.
#0  0xf77db430 in __kernel_vsyscall ()
(gdb) bt
#0  0xf77db430 in __kernel_vsyscall ()
#1  0xf752f1df in raise () from /lib/i386-linux-gnu/libc.so.6
#2  0xf7532825 in abort () from /lib/i386-linux-gnu/libc.so.6
#3  0xf756c39a in ?? () from /lib/i386-linux-gnu/libc.so.6
#4  0xf7576ee2 in ?? () from /lib/i386-linux-gnu/libc.so.6
#5  0xf4be627b in SQString::Release() () from /home/l4duser4/left4dead2/bin/vscript_srv.so
#6  0xf4c0162c in CSquirrelVM::ExternalInstanceReleaseHook(void*, int) () from /home/l4duser4/left4dead2/bin/vscript_srv.so
#7  0xf4bd2f6a in SQInstance::Release() () from /home/l4duser4/left4dead2/bin/vscript_srv.so
#8  0xf4bebee1 in RefTable::Release(tagSQObject&) () from /home/l4duser4/left4dead2/bin/vscript_srv.so
#9  0xf4c02b80 in CSquirrelVM::ReleaseScriptObject(HSCRIPT__*) () from /home/l4duser4/left4dead2/bin/vscript_srv.so
#10 0xeedf0d34 in CBaseEntity::~CBaseEntity() () from /home/l4duser4/left4dead2/left4dead2/bin/server_srv.so
#11 0xef08fe42 in CInfoRemarkable::~CInfoRemarkable() () from /home/l4duser4/left4dead2/left4dead2/bin/server_srv.so
#12 0xeee537e0 in CGlobalEntityList::CleanupDeleteList() () from /home/l4duser4/left4dead2/left4dead2/bin/server_srv.so
#13 0xeee55735 in CGlobalEntityList::Clear() () from /home/l4duser4/left4dead2/left4dead2/bin/server_srv.so
#14 0xeee9cbf7 in CServerGameDLL::LevelShutdown() () from /home/l4duser4/left4dead2/left4dead2/bin/server_srv.so
#15 0xea440fe0 in __SourceHook_MFHCls_SGD_LevelShutdown::Func() ()
   from /home/l4duser4/left4dead2/update/../left4dead2/addons/metamod/bin/metamod.2.l4d2.so
#16 0xf6ce0b7c in CServerPlugin::LevelShutdown() () from /home/l4duser4/left4dead2/bin/engine_srv.so
#17 0xf6c647d5 in CHostState::State_ChangeLevelMP() () from /home/l4duser4/left4dead2/bin/engine_srv.so
#18 0xf6c64c21 in CHostState::FrameUpdate(float) () from /home/l4duser4/left4dead2/bin/engine_srv.so
#19 0xf6c64cf9 in HostState_Frame(float) () from /home/l4duser4/left4dead2/bin/engine_srv.so
#20 0xf6cf07e3 in CEngine::Frame() () from /home/l4duser4/left4dead2/bin/engine_srv.so
#21 0xf6ced8f6 in CDedicatedServerAPI::RunFrame() () from /home/l4duser4/left4dead2/bin/engine_srv.so
#22 0xf6f46a6c in RunServerIteration(bool) () from bin/dedicated_srv.so
#23 0xf6f46b08 in RunServer(bool) () from bin/dedicated_srv.so
#24 0xf6ced9dd in CModAppSystemGroup::Main() () from /home/l4duser4/left4dead2/bin/engine_srv.so
#25 0xf6d3ead0 in CAppSystemGroup::Run() () from /home/l4duser4/left4dead2/bin/engine_srv.so
#26 0xf6cedc7f in CDedicatedServerAPI::ModInit(ModInfo_t&) () from /home/l4duser4/left4dead2/bin/engine_srv.so
#27 0xf6f46be0 in CDedicatedAppSystemGroup::Main() () from bin/dedicated_srv.so
#28 0xf6f65a20 in CAppSystemGroup::Run() () from bin/dedicated_srv.so
#29 0xf6f65a20 in CAppSystemGroup::Run() () from bin/dedicated_srv.so
#30 0xf6f12415 in main () from bin/dedicated_srv.so
#31 0x080486f1 in main ()

Last edited by Martijn79; 07-29-2013 at 12:29.
Martijn79 is offline
dcx2
Senior Member
Join Date: Sep 2011
Old 07-29-2013 , 12:50   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #563

I dunno what to say. Do make absolutely sure that your gamedata is truly updated, though...I fixed a Linux sig about two hours ago that would be suspiciously close to that crash Electr0 posted. Make sure it says "@_ZNK11SurvivorBot16FindScavengeItemEf" in your gamedata. I know that SurvivorCheckpointLeaving::Update(SurvivorBot *, float) calls both of my forwards, so it could be either one, but they both work in Windows (Plugin_Continue and Plugin_Handled, and Plugin_Continue is the default if no plugins use the forward), so the only thing I can think of is that somehow the arguments are different for Linux?

Either way you guys will have to wait til I get home from work to poke around and see exactly which call failed and why. In the mean time, commenting out the Linux sigs for either/both of UseHealingItems and FindScavengeItem should stop the crashing for the binary Martijn posted.
__________________

Last edited by dcx2; 07-29-2013 at 13:02.
dcx2 is offline
Electr000999
Senior Member
Join Date: Aug 2011
Old 07-29-2013 , 13:42   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #564

Martijn79, yes I previously used a https://forums.alliedmods.net/showpo...&postcount=525 work fine,i used last snapshots 1.5
Electr000999 is offline
Send a message via Skype™ to Electr000999
dcx2
Senior Member
Join Date: Sep 2011
Old 07-29-2013 , 20:29   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #565

Okay, it was SurvivorBot::UseHealingItems causing your crash. (actually, the mov eax after the call)

But I don't understand *why* it causes the crash. I mean, the detour defaults to Plugin_Continue, which doesn't change any values.

The only thing I can see is that, in the Windows disassembly, there are two args on the stack, and one arg passed via ecx (EDIT: "thiscall" calling convention). On Linux, all three args are passed on the stack. But IDA shows five args for Linux. IDA also says _fastcall for Linux, and Wikipedia says that GCC's fastcall passes two args in ecx:edx. But the values in ecx:edx are unused by the function; they just get overwritten later, which makes me think they're being treated like local automatic variables instead of arguments, and that the compiler made it _fastcall so it didn't have to make room for those locals.

EDIT: Also odd...the order of args for Windows appears to be (survivorbot, action, unused), while the order of args for Linux appears to be (action, survivorbot, unknown). Is it possible that the different order of arguments is causing the problem?
__________________

Last edited by dcx2; 07-29-2013 at 23:19.
dcx2 is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-29-2013 , 23:32   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #566

Quote:
Originally Posted by dcx2 View Post
Okay, it was SurvivorBot::UseHealingItems causing your crash. (actually, the mov eax after the call)

But I don't understand *why* it causes the crash. I mean, the detour defaults to Plugin_Continue, which doesn't change any values.

The only thing I can see is that, in the Windows disassembly, there are two args on the stack, and one arg passed via ecx (EDIT: "thiscall" calling convention). On Linux, all three args are passed on the stack. But IDA shows five args for Linux. IDA also says _fastcall for Linux, and Wikipedia says that GCC's fastcall passes two args in ecx:edx. But the values in ecx:edx are unused by the function; they just get overwritten later, which makes me think they're being treated like local automatic variables instead of arguments, and that the compiler made it _fastcall so it didn't have to make room for those locals.

EDIT: Also odd...the order of args for Windows appears to be (survivorbot, action, unused), while the order of args for Linux appears to be (action, survivorbot, unknown). Is it possible that the different order of arguments is causing the problem?
This is only one arg, the action.

The other things that you are seeing are a result of the return type being a struct returned by value, which gets assembled differently depending on the platform and the size of the struct.

Last edited by psychonic; 07-29-2013 at 23:32. Reason: GRAMMAR
psychonic is offline
dcx2
Senior Member
Join Date: Sep 2011
Old 07-29-2013 , 23:50   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #567

Well, two args if you count the this pointer. And I know you say there's only one arg, but when I tried to detour UseHealingItems with only one arg, it would crash my Windows server. I had to use two args + this pointer for the UseHealingItems detour to work.

This function is very odd. For one, Linux actually uses what I referred to as the "unknown" arg. It just writes a couple zeros to it, sometimes. But Windows does not use the arg at all, even though it's passed on the stack. Is this an artifact of that struct returned by value?

Also, I thought that the this pointer was always the last argument pushed onto the stack (or in the case of thiscall, passed in ecx). But for Linux it looks like the last arg on the stack is the Action. Doesn't that mean the order of the args changed? Why would Windows this pointer be passed as the second arg in Linux?
__________________

Last edited by dcx2; 07-29-2013 at 23:53.
dcx2 is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-30-2013 , 00:03   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #568

Quote:
Originally Posted by dcx2 View Post
This function is very odd. For one, Linux actually uses what I referred to as the "unknown" arg. It just writes a couple zeros to it, sometimes. But Windows does not use the arg at all, even though it's passed on the stack. Is this an artifact of that struct returned by value?

Yes.

The linux symbol tells you the exact, correct argument types (or type, in this case) and order (aside from the thisptr). The rest is due to the return type.

If you were to figure out the struct and add it to the code, and putting it as the return type, the compiler on each platform would generate exactly what you are seeing.
psychonic is offline
dcx2
Senior Member
Join Date: Sep 2011
Old 07-30-2013 , 00:40   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #569

Ah, I did a bit more reading on calling conventions. For cdecl, it said that sometimes non-POD data types >64bits (e.g. struct with 3 DWORDs) will be returned "by hidden parameter on the stack". I'm guessing this is what you mean.

I'm still confused why I need two args for my detour to work in Windows, and why having only one arg fails. Is it because my detour needs to make the hidden parameter explicit? For detours, do I need to pass thisptr explicitly? I don't see any other detours doing that...

I looked at some other functions, and I'm becoming more and more certain that the order of the arguments changes between the Windows and Linux versions. Unlike the other detours I've examined, thisptr for Windows is definitely not the first argument in Linux for UseHealingItems.

EDIT:

I compared Martijn's .so to the Linux disassembly. The args are (probably) passed correctly, so I don't think that's the problem anymore (although it's still weird that the argument order was rearranged...). But I think I see what's causing the problem now.

The calling convention used by UseHealingItems doesn't match anything I've seen before. It looks like the callee is allocating space on the stack for its own arguments (??) but I assume this is just gcc's way of optimizing things. But it gets weirder! After the callee clears its stack, it executes RETN 4 - but all the arguments are already cleared! And sure enough, if you follow it back to the caller, the caller is doing a SUB esp, 4 to undo the unnecessary RETN 4.

So here's my theory. The game gets detoured. I jump on the trampoline. When execution returns, the RETN 4 has corrupted the stack, and since the compiler didn't add a SUB esp, 4 to compensate, my detour's function epilogue is screwed (it probably ends up popping the return address into ebp or something like that)

Now, I can compensate for this with some dirty in-line assembly right after the function call. BUT the problem is that my detour's epilogue ends with RETN 0 - but the game is expecting UseHealingItems to RETN 4! So when the game tries to uncorrupt the stack, it will screw everything up again. The only thing I can think of to fix this is patching the extension after its built, so that it does RETN 4. But RETN 0 is a one-byte instruction, and RETN 4 has three bytes, but there's alignment padding that I can probably take advantage of for the extra 2 bytes.

...so, does any of that make any sense to anyone else, or do I just sound crazy? I remember reading that compilers are free to come up with their own non-standard calling conventions if a function is declared static, so is that a possible explanation for the odd behavior I'm seeing?
__________________

Last edited by dcx2; 07-31-2013 at 01:10. Reason: Further investigation
dcx2 is offline
ProdigySim
SourceMod Plugin Approver
Join Date: Feb 2010
Old 07-31-2013 , 05:21   Re: [EXTENSION] Left 4 Downtown 2 (0.5.4.2) - L4D2 Only, Updated Left4Downtown
Reply With Quote #570

You need to set up the call as a thiscall for one. Look at how the CThrow::ActivateAbility detour is set up. Or, heck, 90% of our detours...
ProdigySim is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode