Should we rename os:: functions that are named like standard C- or Posix-functions?

Thomas Stüfe thomas.stuefe at gmail.com
Mon Jul 4 07:18:37 UTC 2022


On Sun, Jul 3, 2022 at 10:59 PM Kim Barrett <kim.barrett at oracle.com> wrote:

> > On Jul 3, 2022, at 4:47 AM, Thomas Stüfe <thomas.stuefe at gmail.com>
> wrote:
> >
> > I am preparing a patch to forbid C-heap allocation functions in hotspot
> as you proposed (https://github.com/openjdk/jdk/pull/9356).
> >
> > Interestingly, not all occurrences of forbidden functions are found
> everywhere. I found that if I compile on Ubuntu 20.04 with gcc 10.3., it
> does not complain about "realpath" even though I forbade it. If I build on
> Alpine, gcc 10.3.1, it finds occurrences of realpath.
>
> In which build variants?  All?  Or only fastdebug?  If the latter, this
> might be another case of
> _FORTIFY_SOURCE rewriting the call first, dodging the warning.  This is
> mentioned in the
> comment describing the gcc implementation of FORBID_C_FUNCTION.
>
>
No, it fails also on release to recognize realpath. Just to be sure I
tested the most important other candidates (malloc, free, realloc, calloc,
strdup) and those all work.


> Note also that I didn’t find a way to provide this feature for
> Windows/VisualStudio, and the
> clang implementation didn’t get tested by me.  (Oracle only uses clang
> when building for
> MacOS using Xcode, and no released version of Xcode has a sufficiently
> recent version
> of clang to have the needed feature set.)
>
>
One thing that I dislike is that this requires including
globalDefinitions.hpp. Not every cpp or hpp file may include that. Also,
since in theory, to have 100% coverage, every file and header should
include globalDefinitions.hpp, we may want to move these macros into an own
file to avoid blowing up the dependencies.

But other than that, I like this mechanism. Its very practical.

Cheers, Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-dev/attachments/20220704/285b8344/attachment-0001.htm>


More information about the hotspot-dev mailing list