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

Thomas Stüfe thomas.stuefe at gmail.com
Thu Jun 30 04:57:10 UTC 2022


Hi,

several functions in the os:: name scope are deliberately named like the
official counterparts they replace:

os::malloc, os::free, os::strdup, os::realloc, os::recv, os::send,
os::connect, os::signal...

There may be more. Some of them argument-match their counterparts (e.g.
os::free), while others don't.

Since the os:: variants can be called inside the os:: namespace with
omitting the leading os::, name confusions are possible. "free(p)" means
something different in global scope or inside an os:: function.

This can lead to problems that are difficult to find, e.g., mismatched
(os::)malloc->(os::)free with the potential to corrupt the C-heap:

https://bugs.openjdk.org/browse/JDK-8289477

And I remember having similar problems in the past. They don't happen
often, but if they do, they take some investigation time since they are
rarely obvious.

I discussed the above problem with the muslc devs
https://www.openwall.com/lists/musl/2022/06/29/3, and their position is
understandable that we should not use names of standard functions.

So I wonder if we should do that. Rename os::<function> to something like
os::<prefix><function>. And what the prefix or suffix would be.

Thanks, Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-dev/attachments/20220630/e17e018e/attachment.htm>


More information about the hotspot-dev mailing list