Skip to content

Comment on Indirect Calling of Nested Functions on GCC Without Executable Stackparent

Comments

C# does closures by creating a class. When you run the function, captured local variables actually live inside the object instead of in the stack. This makes use of an object, but no memory pages need to become read/write/executable to make C#-style closures happen. You just have a combination function/object pointer (a delegate) instead of a single function pointer.

Question isn't how can a function closure be represented anywhere, but how it can be represented in a way that can be aliased by a vanilla C function-pointer, which is a more specific and challenging question.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.