tech-kern archive

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

Re: valgrind




> On Mar 22, 2022, at 5:11 PM, Rhialto <rhialto%falu.nl@localhost> wrote:
> 
> On Tue 22 Mar 2022 at 20:59:05 +0000, Koning, Paul wrote:
> ...
>> If it does, that would mean you can't get a pointer to a nested
>> function, which is no different from the C++ rule that you can't get a
>> (plain function) pointer to a member function.
> 
> True. But the trampoline function on the stack are only needed to create
> a pointer to a nested function. I don't think there is any issue if you
> never create such pointers. But that would make nested functions a lot
> less useful. You couldn't use one with qsort(3) for instance (as the
> comparison function), which is exactly the sort of scenario that would
> be perfect for a nested function.

Yes, though in that case the pointer is of a specific type, so you don't
need what you pointed out as missing, the generic function pointer.

> Possibly, a trampoline could be created on the heap, and then made
> executable and un-writable. Maybe that's considered too complicated /
> system dependent / expensive by gcc?

Perhaps.  But the bigger issue is that the heap isn't normally 
executable either, and all the same arguments for why the stack
should not be executable apply to the heap also.

	paul



Home | Main Index | Thread Index | Old Index