Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hotspot/os/aix/forbiddenFunctions_aix.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/aix/permitForbiddenFunctions_aix.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/aix/porting_aix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ bool AixSymbols::get_function_name (
p_name[namelen-1] = '\0';
}
if (demangled_name != nullptr) {
permit_forbidden_functions::free(demangled_name);
permit_forbidden_function::free(demangled_name);
}
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/os/bsd/decoder_machO.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -46,7 +46,7 @@ bool MachODecoder::demangle(const char* symbol, char *buf, int buflen) {
if ((result = abi::__cxa_demangle(symbol, nullptr, nullptr, &status)) != nullptr) {
jio_snprintf(buf, buflen, "%s", result);
// call c library's free
permit_forbidden_functions::free(result);
permit_forbidden_function::free(result);
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/bsd/forbiddenFunctions_bsd.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/bsd/permitForbiddenFunctions_bsd.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/os/linux/decoder_linux.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -48,7 +48,7 @@ bool ElfDecoder::demangle(const char* symbol, char *buf, int buflen) {
if ((result = abi::__cxa_demangle(symbol, nullptr, nullptr, &status)) != nullptr) {
jio_snprintf(buf, buflen, "%s", result);
// call c library's free
permit_forbidden_functions::free(result);
permit_forbidden_function::free(result);
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/linux/forbiddenFunctions_linux.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/os/linux/gc/z/zMountPoint_linux.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -64,11 +64,11 @@ char* ZMountPoint::get_mountpoint(const char* line, const char* filesystem) cons
strcmp(line_filesystem, filesystem) != 0 ||
access(line_mountpoint, R_OK|W_OK|X_OK) != 0) {
// Not a matching or accessible filesystem
permit_forbidden_functions::free(line_mountpoint);
permit_forbidden_function::free(line_mountpoint);
line_mountpoint = nullptr;
}

permit_forbidden_functions::free(line_filesystem);
permit_forbidden_function::free(line_filesystem);

return line_mountpoint;
}
Expand All @@ -92,14 +92,14 @@ void ZMountPoint::get_mountpoints(const char* filesystem, ZArray<char*>* mountpo
}

// readline will return malloced memory. Need raw ::free, not os::free.
permit_forbidden_functions::free(line);
permit_forbidden_function::free(line);
fclose(fd);
}

void ZMountPoint::free_mountpoints(ZArray<char*>* mountpoints) const {
ZArrayIterator<char*> iter(mountpoints);
for (char* mountpoint; iter.next(&mountpoint);) {
permit_forbidden_functions::free(mountpoint); // *not* os::free
permit_forbidden_function::free(mountpoint); // *not* os::free
}
mountpoints->clear();
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/os/linux/mallocInfoDcmd.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -56,7 +56,7 @@ void MallocInfoDcmd::execute(DCmdSource source, TRAPS) {
ShouldNotReachHere();
}
::fclose(stream);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that fclose was never forbidden, so the ALLOW_C_FUNCTION was not needed.

permit_forbidden_functions::free(buf);
permit_forbidden_function::free(buf);
#else
_output->print_cr(malloc_info_unavailable);
#endif // __GLIBC__
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/linux/permitForbiddenFunctions_linux.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/posix/forbiddenFunctions_posix.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/os/posix/os_posix.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -931,11 +931,11 @@ ssize_t os::connect(int fd, struct sockaddr* him, socklen_t len) {
}

void os::exit(int num) {
permit_forbidden_functions::exit(num);
permit_forbidden_function::exit(num);
}

void os::_exit(int num) {
permit_forbidden_functions::_exit(num);
permit_forbidden_function::_exit(num);
}

void os::naked_yield() {
Expand Down Expand Up @@ -992,15 +992,15 @@ char* os::realpath(const char* filename, char* outbuf, size_t outbuflen) {
// This assumes platform realpath() is implemented according to POSIX.1-2008.
// POSIX.1-2008 allows to specify null for the output buffer, in which case
// output buffer is dynamically allocated and must be ::free()'d by the caller.
char* p = permit_forbidden_functions::realpath(filename, nullptr);
char* p = permit_forbidden_function::realpath(filename, nullptr);
if (p != nullptr) {
if (strlen(p) < outbuflen) {
strcpy(outbuf, p);
result = outbuf;
} else {
errno = ENAMETOOLONG;
}
permit_forbidden_functions::free(p); // *not* os::free
permit_forbidden_function::free(p); // *not* os::free
} else {
// Fallback for platforms struggling with modern Posix standards (AIX 5.3, 6.1). If realpath
// returns EINVAL, this may indicate that realpath is not POSIX.1-2008 compatible and
Expand All @@ -1009,7 +1009,7 @@ char* os::realpath(const char* filename, char* outbuf, size_t outbuflen) {
// a memory overwrite.
if (errno == EINVAL) {
outbuf[outbuflen - 1] = '\0';
p = permit_forbidden_functions::realpath(filename, outbuf);
p = permit_forbidden_function::realpath(filename, outbuf);
if (p != nullptr) {
guarantee(outbuf[outbuflen - 1] == '\0', "realpath buffer overwrite detected.");
result = p;
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/os/posix/permitForbiddenFunctions_posix.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -31,7 +31,7 @@
// Provide wrappers for some functions otherwise forbidden from use in HotSpot.
// See forbiddenFunctions.hpp for details.

namespace permit_forbidden_functions {
namespace permit_forbidden_function {
BEGIN_ALLOW_FORBIDDEN_FUNCTIONS

// Used by the POSIX implementation of os::realpath.
Expand All @@ -40,6 +40,6 @@ inline char* realpath(const char* path, char* resolved_path) {
}

END_ALLOW_FORBIDDEN_FUNCTIONS
} // namespace permit_forbidden_functions
} // namespace permit_forbidden_function

#endif // OS_POSIX_PERMITFORBIDDENFUNCTIONS_POSIX_HPP
2 changes: 1 addition & 1 deletion src/hotspot/os/windows/forbiddenFunctions_windows.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/os/windows/os_windows.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -4383,9 +4383,9 @@ static void exit_process_or_thread(Ept what, int exit_code) {
if (what == EPT_THREAD) {
_endthreadex((unsigned)exit_code);
} else if (what == EPT_PROCESS) {
permit_forbidden_functions::exit(exit_code);
permit_forbidden_function::exit(exit_code);
} else { // EPT_PROCESS_DIE
permit_forbidden_functions::_exit(exit_code);
permit_forbidden_function::_exit(exit_code);
}

// Should not reach here
Expand Down Expand Up @@ -5148,15 +5148,15 @@ char* os::realpath(const char* filename, char* outbuf, size_t outbuflen) {
}

char* result = nullptr;
char* p = permit_forbidden_functions::_fullpath(nullptr, filename, 0);
char* p = permit_forbidden_function::_fullpath(nullptr, filename, 0);
if (p != nullptr) {
if (strlen(p) < outbuflen) {
strcpy(outbuf, p);
result = outbuf;
} else {
errno = ENAMETOOLONG;
}
permit_forbidden_functions::free(p); // *not* os::free
permit_forbidden_function::free(p); // *not* os::free
}
return result;
}
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/os/windows/permitForbiddenFunctions_windows.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -31,7 +31,7 @@
// Provide wrappers for some functions otherwise forbidden from use in HotSpot.
// See forbiddenFunctions.hpp for details.

namespace permit_forbidden_functions {
namespace permit_forbidden_function {
BEGIN_ALLOW_FORBIDDEN_FUNCTIONS

// Used by the Windows implementation of os::realpath.
Expand All @@ -40,6 +40,6 @@ inline char* _fullpath(char* absPath, const char* relPath, size_t maxLength) {
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we forbid the non Standard _snprintf too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll add that. We should also technically be forbidding snprintf in favor of os::snprintf, but the difference
is pretty minuscule and there are a significant number of occurrences (125 today).

END_ALLOW_FORBIDDEN_FUNCTIONS
} // namespace permit_forbidden_functions
} // namespace permit_forbidden_function

#endif // OS_WINDOWS_PERMITFORBIDDENFUNCTIONS_WINDOWS_HPP
6 changes: 3 additions & 3 deletions src/hotspot/os/windows/symbolengine.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -104,7 +104,7 @@ class SimpleBufferWithFallback {
virtual void initialize () {
assert(_p == nullptr && _capacity == 0, "Only call once.");
const size_t bytes = OPTIMAL_CAPACITY * sizeof(T);
T* q = (T*) permit_forbidden_functions::malloc(bytes);
T* q = (T*) permit_forbidden_function::malloc(bytes);
if (q != nullptr) {
_p = q;
_capacity = OPTIMAL_CAPACITY;
Expand All @@ -120,7 +120,7 @@ class SimpleBufferWithFallback {
// case, where two buffers need to be of identical capacity.
void reset_to_fallback_capacity() {
if (_p != _fallback_buffer) {
permit_forbidden_functions::free(_p);
permit_forbidden_function::free(_p);
}
_p = _fallback_buffer;
_capacity = (int)(sizeof(_fallback_buffer) / sizeof(T));
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/jvmci/jvmciEnv.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -614,7 +614,7 @@ JVMCIEnv::~JVMCIEnv() {
if (_init_error_msg != nullptr) {
// The memory allocated in libjvmci was not allocated with os::malloc
// so must not be freed with os::free.
permit_forbidden_functions::free((void*)_init_error_msg);
permit_forbidden_function::free((void*)_init_error_msg);
}
if (_init_error != JNI_OK) {
return;
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/logging/logTagSet.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -150,7 +150,7 @@ void LogTagSet::vwrite(LogLevelType level, const char* fmt, va_list args) {
} else {
// Buffer too small, allocate a large enough buffer using malloc/free to avoid circularity.
// Since logging is a very basic function, conceivably used within NMT itself, avoid os::malloc/free
char* newbuf = (char*)permit_forbidden_functions::malloc(newbuf_len * sizeof(char));
char* newbuf = (char*)permit_forbidden_function::malloc(newbuf_len * sizeof(char));
if (newbuf != nullptr) {
prefix_len = _write_prefix(newbuf, newbuf_len);
ret = os::vsnprintf(newbuf + prefix_len, newbuf_len - prefix_len, fmt, saved_args);
Expand All @@ -160,7 +160,7 @@ void LogTagSet::vwrite(LogLevelType level, const char* fmt, va_list args) {
if (ret < 0) {
log(level, "Log message newbuf issue");
}
permit_forbidden_functions::free(newbuf);
permit_forbidden_function::free(newbuf);
} else {
// Native OOM, use buf to output the least message. At this moment buf is full of either
// truncated prefix or truncated prefix + string. Put trunc_msg at the end of buf.
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/nmt/mallocSiteTable.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -43,7 +43,7 @@ const MallocSiteHashtableEntry* MallocSiteTable::_hash_entry_allocation_site = n
* time, it is in single-threaded mode from JVM perspective.
*/
bool MallocSiteTable::initialize() {
_table = (MallocSiteHashtableEntry**)permit_forbidden_functions::calloc(table_size, sizeof(MallocSiteHashtableEntry*));
_table = (MallocSiteHashtableEntry**)permit_forbidden_function::calloc(table_size, sizeof(MallocSiteHashtableEntry*));
if (_table == nullptr) {
return false;
}
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/share/nmt/memMapPrinter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -98,8 +98,8 @@ class CachedNMTInformation : public VirtualMemoryWalker {
_count(0), _capacity(0), _last(0) {}

~CachedNMTInformation() {
permit_forbidden_functions::free(_ranges);
permit_forbidden_functions::free(_mem_tags);
permit_forbidden_function::free(_ranges);
permit_forbidden_function::free(_mem_tags);
}

bool add(const void* from, const void* to, MemTag mem_tag) {
Expand All @@ -114,8 +114,8 @@ class CachedNMTInformation : public VirtualMemoryWalker {
// Enlarge if needed
const size_t new_capacity = MAX2((size_t)4096, 2 * _capacity);
// Unfortunately, we need to allocate manually, raw, since we must prevent NMT deadlocks (ThreadCritical).
_ranges = (Range*)permit_forbidden_functions::realloc(_ranges, new_capacity * sizeof(Range));
_mem_tags = (MemTag*)permit_forbidden_functions::realloc(_mem_tags, new_capacity * sizeof(MemTag));
_ranges = (Range*)permit_forbidden_function::realloc(_ranges, new_capacity * sizeof(Range));
_mem_tags = (MemTag*)permit_forbidden_function::realloc(_mem_tags, new_capacity * sizeof(MemTag));
if (_ranges == nullptr || _mem_tags == nullptr) {
// In case of OOM lets make no fuss. Just return.
return false;
Expand Down
Loading