pawn-lang / compiler

Pawn compiler for SA-MP with bug fixes and new features - runs on Windows, Linux, macOS
Other
306 stars 72 forks source link

Crash - (maybe from assembly in a destructor). #318

Open Y-Less opened 6 years ago

Y-Less commented 6 years ago

Is this a BUG REPORT, FEATURE REQUEST or QUESTION?:

What happened:

Assertion failed: sym->refer[i]->ident==iFUNCTN, file d:\work\sa-mp\pawn\source\compiler\sc1.c, line 4725

It seemed to have a load of refers to the function DisasmReloc.

What you expected to happen:

Not crash.

How to reproduce it (as minimally and precisely as possible):

stock operator~(I@T:inlines[], size)
{
    // This destructor is actually only ever called once, even though it might
    // exist many times in the compiled code; the rest are replaced at init time
    // using information gathered here.
    #pragma unused inlines
    // Get the return address.
    #emit LOAD.S.alt       4
    // Read the code before the return.
    #emit LCTRL            0
    #emit ADD
    #emit MOVE.alt
    #emit LCTRL            1
    #emit SUB.alt
    #emit ADD.C            0xFFFFFFFC
    #emit STOR.S.pri       size
    #emit LREF.S.pri       size
    #emit STOR.S.pri       size
    YSI_g_sInlineLinkedList = DisasmReloc(size);
}

Anything else we need to know?:

Environment:

Y-Less commented 6 years ago

Reproduction:

#define _DEBUG 1
#define YSI_TESTS

#include <a_samp>
#include <YSI_Coding\y_inline>

main()
{
}

With this exact commit:

https://github.com/pawn-lang/YSI-Includes/tree/f1b0c8815ffc3f051c71a5ae230e143e3216cc54

However, note that I discovered two bugs on the same code, so this one won't trigger until the other one (#317) is fixed.

Y-Less commented 6 years ago

This is how I worked around it:

https://github.com/pawn-lang/YSI-Includes/blob/9342257f007cdb92f7a0f3bdc3ac6c66121c657c/YSI_Coding/y_inline/y_inline_impl2.inc#L247-L260

I have no idea why that helped, but it did.

YashasSamaga commented 6 years ago

https://github.com/pawn-lang/compiler/issues/259 related?

Y-Less commented 6 years ago

It could be, in which case the crash is more general. That issue I know involved two overloads, this one didn't, so I made a new issue, but maybe they are two separate manifestations of the same issue (which would make a lot of sense).

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.