Skip to content

Commit

Permalink
Very bad fix for the y_ebc random crash.
Browse files Browse the repository at this point in the history
I don't know why, but just calling another function from inside the operator seems to crash the compiler randomly.
  • Loading branch information
Alex Cole committed Sep 2, 2023
1 parent 5dd6865 commit 1be9840
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion YSI_Coding/y_inline/y_inline_impl.inc
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Optional plugins:
#define callback: F@_@:

stock
YSI_g_sCodSize,
InlineRet:YSI_gInlineRet = InlineRet:0;

stock Callback_Return_(value)
Expand Down Expand Up @@ -291,7 +292,35 @@ stock Inline_EBC__(owner, tag)

stock operator*(@Ik:func, ebc)
{
Indirect_SetOwner(func, ebc);
// This operator crashes the compiler if we try to call another function
// from inside it. Why? No clue, but as a result I've had to completely
// inline the code in here. It is not a good situation! This is very
// internal `indirection` implementation details, which should not be
// exposed here, but there's not really another choice - just calling any
// other function, even a local empty one, causes the crash.
new tmp = _:func;
if (tmp >= YSI_g_sCodSize)
{
// Get the data at `func - COD`.
#emit LOAD.S.pri tmp
#emit LOAD.alt YSI_g_sCodSize
#emit SUB
#emit MOVE.alt
#emit LOAD.I
#emit STOR.S.pri tmp
if (tmp)
{
// Probably a string.
return _:func;
}
{}
#emit STOR.S.alt tmp
// Store the owner.
tmp += E_INDIRECTION_OWNER__;
ebc |= cellmin;
#emit LOAD.S.pri ebc
#emit SREF.S.pri tmp
}
return _:func;
}

Expand Down Expand Up @@ -691,6 +720,14 @@ public OnCodeInit()
new tmp[2];
strunpack(tmp, tmp);
}
if (!YSI_g_sCodSize)
{
AddressofResolve();
new
amxhdr[AMX_HDR];
GetAmxHeader(amxhdr);
YSI_g_sCodSize = amxhdr[AMX_HDR_DAT] - amxhdr[AMX_HDR_COD];
}

new scanner[CodeScanner];
CodeScanInit(scanner);
Expand Down

0 comments on commit 1be9840

Please sign in to comment.