Re: nested functions



Tommy Thorn wrote:
Trampolines may in fact be the best choice if you expect most
functions passed by argument to *not* have a local environment (such
as global "outer" functions). The obvious alternative is to pass a
pointer to a structure which includes the local environment [pointer]
as well as a pointer to the function. This is better if the opposite
is true.

Before choosing trampolines you also need to consider security, e.g., if
you want to implement web services, trampolines may be unacceptable.
Trampolines in the GCC implementation are implemented by generating code
at runtime and locating it on the stack. This means that the program
must execute from user writable store.

One of the most dangerous forms of hacking attack are when the buffer
overrun attacks, were the hacker sends code to the web service under
attack and fools the service into executing it. The code is stored in
and executed from user writable store. Modern hardware including modern
x86 hardware can check that code is fetched from store marked for
storing code. Of course the operating systems (including newer versions
of Linux and Windows) by default does not allow executing code stored in
user writable areas.

You will have to disable such hardware checks if you want to use GCCs
trampolines, but that is unacceptable for security reasons.

Karsten Nyblad

.



Relevant Pages

  • Re: nested functions
    ... I don't know GPC, ... Trampolines may in fact be the best choice if you expect most ... pointer to a structure which includes the local environment [pointer] ...
    (comp.compilers)
  • Re: Stack frames & static predecessors
    ... don't need a static chain pointer). ... Trampolines are problematic, ... trampolines make perfect sense for the gcc dialect of C. ... still construct the display from scratch from the static chain on ...
    (comp.compilers)
  • Re: DirectShow Insanity
    ... its a strange one, but since it only fails in this little test app, it must ... somewhere there is a null pointer... ... > The exception happens immediately upon executing the ...
    (microsoft.public.win32.programmer.directx.audio)
  • Re: Starting to use STL containers...
    ... > implies creating the object, executing the constructor, which I'm not ... > your code does) and then return a pointer to this object. ... to a list without executing a constructor somewhere. ...
    (comp.lang.cpp)
  • Re: How to gracefully terminate threads when ActiveX container (internet explorer) closes
    ... thread in turn allocates a BYTE * pointer and opens a file from disk. ... In this loop I am sending files through a socket. ... this loop is executing, my thread does not receive messages. ... Please shine a light on me :-) I will post code if needed but I ...
    (microsoft.public.win32.programmer.ole)