Closed nyankers closed 3 years ago
From debugging this, it looks like this may be happening because PP::clear()
will call Macro::clear()
before TokenBuf::clear()
. TokenBuf::pop()
only frees the buffer under certain circumstances, and in this case (where fd < -1
), that requires the macro to be intact, but because Macro::clear()
is called first in this scenario, mc->narg
will contain junk data.
I don't know if there's any reason for this ordering, but considering TokenBuf
uses Macro
and not the other way around, I'd think it makes logical sense to swap the two statements.
Nice work!
This took a while to narrow down and recreate.
Suppose you try to compile the following invalid LPC file:
This will fail to compile, which is itself correct, but then upon rebooting the server (e.g.
hotboot
as a System user,reboot
as any user, etc.), the following message will pop up on the server (which causes a hotboot to fail):I've only just been able to reproduce it, so I've not done further analysis yet. At first, I expected
A(1,2)
to be the problem element, but it appears it's failing onB(1)
(a correct macro expansion into function) following the incorrect one. I also thought reaching the function limit with macros could cause this, but if so, I haven't been able to reproduce that so far. This issue has been pretty insidious to track down, since I won't find out for hours or days later, long after I solved the LPC issue that caused it.