Re: Nested functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ian Lance Taylor <ian@xxxxxxxx> writes:

> Marco Gerards <mgerards@xxxxxxxxx> writes:
>
>> There have been quite some "bug reports" for a project I work on
>> lately related to nested functions.  Although I don't know the
>> internals of gcc, it seems that sometimes trampolines are used when a
>> function pointer to the nested function is passed to another function.
>> 
>> Two "bugs" have been reported:
>> 
>> 1) It doesn't build under Mac OSX.
>> 2) The program does not execute when the stack is not executable.
>> 
>> The first problem is caused by apple, regardless of whether
>> trampolines are required or not, the program, AFAIK, does not build.
>> 
>> The second problem is caused because some OS'es have no executable
>> stack.  Redhat even removes the nested functions from our code so it
>> builds for them.  But of course it would be better for all of our
>> users if it just works.
>
> The implementation of nested functions requires using a trampoline
> when you pass the address of a nested function to another function.
> That is not a bug.

Right, that's why I said "bug" and not bug.  It just bothers me that
my code does not compile on some operating systems.

> For most if not all targets these trampolines are created on the
> stack, and thus require the stack to be executable.  On GNU/Linux, the
> program will normally be annotated to indicate that it requires an
> executable stack (I'm not sure what you mean when you say that Red Hat
> removes the nested functions).  On NetBSD and other operating systems,
> the compiler will insert a call to a system call to make the stack
> executable.  There may be other strategies used on other systems.  I
> don't know the status of trampolines on Mac OS/X.  Note that Apple
> ships a patched version of gcc.

I was told that redhat does not want to use programs with an
executable stack.  So what they do for this specific program is
rewriting some procedures so no nested functions are used anymore.

I am aware that Apple ships a broken version of gcc.  I am just asking
here to get an official feedback from the GCC maintainers.  I am
getting user feedback like "Nested functions are broken", "Nested
functions are deprecated", etc.  This irritates me a lot because I
like GCC and I personally don't care about the crazy ideas some people
have about security while I don't see it as my concern. ;)

>> 1) Is there a fix for this or has this been fixed?
>
> I don't know what the bug is, so I don't know whether it has been
> fixed.

Sorry, I should choose my words more carefully.  Are nested functions
being deprecated?  Are there plans to use something else than an
executable stack to implement trampolines?

>> 2) What is the official stance of the GCC maintainers regarding this
>>    issue?  It's a documented feature we like and we rely on.
>
> Nested functions are supposed to work.

Agreed. :-)

> Please check for existing bug reports at http://gcc.gnu.org/bugzilla/,
> and file a new bug report if you don't find one.  See
> http://gcc.gnu.org/bugs.html.  Thanks.

I will do that.

Thanks,
Marco


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux