If you take a closer look at the Pascal source code below there is no need for a trampoline or stub code since the inner function E does not use any variable or parameter in the lexical scope of the containing function Q.
Hence, why does gpc generate a trampoline in this case? how to prevent it?
$ cat crashes.p program Crashes(input,output);
function B(l:integer):boolean; begin B:=true; end;
procedure Q(j:integer;function A(l:integer):boolean);
function E(l:integer):boolean; begin E := false end;
begin if A(j) then Q(200,E); end;
begin Q(100,B); end.
-- Regis
2008/4/4, scott moore samiam@moorecad.com:
Waldek Hebisch wrote:
disallow executing code on the stack. In particular on reasonably new processors Windows can make stack non-executable. So, I suspect that
It was always possible, hardware wise, to make the stack non-executable, from the 80286 on up. On the 80286, it would be done by removing the execute bit from the stack segment. On 80386 or later, by removing execute permissions from the stack pages.
I'd be shocked if he had a windows that disallowed this. It would break hundreds of programs in existence, including several of mine. I use it all the time, you pretty much have to in order to get reasonable thunks.
Scott