Poisoning in HotSpot
Kim Barrett
kim.barrett at oracle.com
Tue Nov 26 16:56:39 UTC 2024
On 11/26/24 4:55 AM, Julian Waters wrote:
> Hi all,
>
> It turned out in the review of
> https://github.com/openjdk/jdk/pull/22069 that the poisoning mechanism
> used in HotSpot can break when combined with LTO. Also, poisoning does
> not work on Windows, at least not with the default Microsoft compiler
> (Though, the Windows/gcc Port also disables FORBID_C_FUNCTION as
> well). I've tried coming up with an alternative mechanism to poison
> methods that works on any platform, but I'm unsure what to do with it
> now. It can be viewed here: https://godbolt.org/z/PKMjjWTxz
>
> Any improvements that could be made to it? Should I continue this so
> we can have a poisoning mechanism that works even while LTO is active?
I think the approach taken in that link won't work, and can't. Try
void* ptr = ::malloc(size_t(1))
No "use of a deleted function" error from that. The problem is that a
non-template exact match is a better match than any template in the overload
set. So calling ::malloc with a size_t argument calls the clib function
rather
than the template in the anonymous namespace.
There's also the "scoped attribute directive ignored" warnings. I remember
reading something about scoped attributes not being as useful as one might
think. Ah, here's part of the discussion:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86368
More information about the hotspot-dev
mailing list