IS4Code / PawnPlus

A SA-MP plugin enhancing the capabilities of the Pawn programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

amx_fork/threaded crash [Linux]

yoranjj opened this issue · comments

Hey again, not quite sure what the issue here is, but;

I've been looking through the documentation examples and have tried a few. A few work and a few just crash the plugin (server).

Tried using this in a command;

new result;
amx_forked(.result=result)
{
    task_yield(1);
    threaded(sync_explicit)
    {
        thread_sleep(1000);
        print("Thread end");
    }
    print("Fork end"); //after 1 s
}
assert result == 1; //immediately

And I get a crash error;

[01:54:23] [debug] Server crashed due to an unknown error
[01:54:23] [debug] Native backtrace:
[01:54:23] [debug] #0 f72e2371 in _Z13GetStackTraceRSt6vectorI10StackFrameSaIS0_EEPv () from plugins/crashdetect.so
[01:54:23] [debug] #1 f72d996d in _ZN18CrashDetectHandler20PrintNativeBacktraceERSoRKN2os7ContextE () from plugins/crashdetect.so
[01:54:23] [debug] #2 f72da98d in _ZN18CrashDetectHandler20PrintNativeBacktraceERKN2os7ContextE () from plugins/crashdetect.so
[01:54:23] [debug] #3 f72dcd1d in _ZN18CrashDetectHandler7OnCrashERKN2os7ContextE () from plugins/crashdetect.so
[01:54:23] [debug] #4 f72e183c in ?? () from plugins/crashdetect.so
[01:54:23] [debug] #5 f76efbd0 in ?? ()
[01:54:23] [debug] #6 f72dc6aa in _ZN18CrashDetectHandler13HandleAMXExecEPii () from plugins/crashdetect.so
[01:54:23] [debug] #7 f72df999 in ?? () from plugins/crashdetect.so
[01:54:23] [debug] #8 f5964406 in ?? () from plugins/streamer.so
[01:54:23] [debug] #9 f564744c in _Z15amx_ExecContextP6tagAMXPiibPN3amx5resetEb () from plugins/PawnPlus.so
[01:54:23] [debug] #10 f5649154 in _Z15amx_ExecContextP6tagAMXPiibPN3amx5resetEb () from plugins/PawnPlus.so
[01:54:23] [debug] #11 f564b9e6 in _ZN5Hooks8amx_ExecEP6tagAMXPii () from plugins/PawnPlus.so
[01:54:23] [debug] #12 706f7264 in ?? () from D��

commented

Hmm, I am not able to reproduce the issue. Can you upload the executable so I can inspect it?

If I'm right, you mean the compiled .so file?

PawnPlus.zip

commented

The crash is at a regular call to amx_Exec. Does the code crash if you remove the inner threaded block, amx_forked or the streamer? Did the same code also crash for older versions?

commented

I also can't test the .so on my server, since it's missing some symbols. Can you build it with make static and send me the .so?

So yeah, the code doesn't crash if I remove the amx_forked block.

PawnPlus.zip

commented

I can't reproduce the issue even with the .so (which works though). Can you please send me the pwn/amx you are testing with?

I would love too, but it is fairly large and requires a lot of includes to compile correctly (going for a "modular" approach). Could it be the command processor (Pawn.CMD) that is interfering with PawnPlus?

commented

I don't think the chance is too high, but perhaps you could isolate the issue into a portable filterscript.

You could also test if there is a difference between these pieces of code:

amx_forked(fork_exec)
{
    print("inside");
}
amx_forked(fork_data)
{
    print("inside");
}
amx_forked(fork_machine)
{
    print("inside");
}

Yeah, I just found out that it isn't caused by Pawn.CMD. Tried all of the pieces of code you listed and the only one that didn't crash (tested in main()) was fork_data, odd.

commented

Strange... Do you have other plugins that could affect the crash, like JIT for example? Does wait_ms work?

wait_ms does work, I'm using the following plugins;

crashdetect.so pawn-redis.so pawncmd.so pawnregex.so pawnraknet.so pawn-memory.so mysql.so sscanf.so streamer.so YSF.so CVector.so PawnPlus.so

Okay, apparently crashdetect was the issue, which is weird because it just installs crash handlers and only gets called when a fatal error occurs... so odd.

commented

crashdetect replaces the implementation of AMX with its own, so it basically controls every execution. I was probably using a version which doesn't cause an issue. Mine is CrashDetect v4.15.1.

commented

Okay, I have downloaded the latest version of CrashDetect and now I can reproduce the crash on Windows as well. Thanks for reporting!

Anytime! I'll be downgrading to v4.15.1 for now, thanks for the help!

commented

If you can compile the latest commit of CrashDetect, can you check please if it works on Linux for you?

Yup, all good now, compiled the latest commit of CrashDetect and used the version of PawnPlus that I statically compiled a way back when we were debugging this.

EDIT: Just wanted to apologize for making you wait this long, busy with something else.