Skip to content

Commit

Permalink
aix permit patches
Browse files Browse the repository at this point in the history
  • Loading branch information
kimbarrett committed Jan 8, 2025
1 parent c478bda commit b774f14
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/hotspot/os/aix/libodm_aix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <string.h>
#include "runtime/arguments.hpp"
#include "runtime/os.hpp"
#include "utilities/permitForbiddenFunctions.hpp"


dynamicOdm::dynamicOdm() {
Expand Down Expand Up @@ -59,7 +60,7 @@ dynamicOdm::~dynamicOdm() {
}


void odmWrapper::clean_data() { if (_data) { free(_data); _data = nullptr; } }
void odmWrapper::clean_data() { if (_data) { permit_forbidden_function::free(_data); _data = nullptr; } }


int odmWrapper::class_offset(const char *field, bool is_aix_5)
Expand Down
17 changes: 10 additions & 7 deletions src/hotspot/os/aix/loadlib_aix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "logging/log.hpp"
#include "utilities/debug.hpp"
#include "utilities/ostream.hpp"
#include "utilities/permitForbiddenFunctions.hpp"

// For loadquery()
#include <sys/ldr.h>
Expand All @@ -55,7 +56,7 @@ class StringList {
// Enlarge list. If oom, leave old list intact and return false.
bool enlarge() {
int cap2 = _cap + 64;
char** l2 = (char**) ::realloc(_list, sizeof(char*) * cap2);
char** l2 = (char**) permit_forbidden_function::realloc(_list, sizeof(char*) * cap2);
if (!l2) {
return false;
}
Expand All @@ -73,7 +74,9 @@ class StringList {
}
}
assert0(_cap > _num);
BEGIN_ALLOW_FORBIDDEN_FUNCTIONS // Temp. until use of forbidden ::strdup fixed.
char* s2 = ::strdup(s);
END_ALLOW_FORBIDDEN_FUNCTIONS
if (!s2) {
return nullptr;
}
Expand Down Expand Up @@ -167,7 +170,7 @@ static void free_entry_list(loaded_module_t** start) {
loaded_module_t* lm = *start;
while (lm) {
loaded_module_t* const lm2 = lm->next;
::free(lm);
permit_forbidden_function::free(lm);
lm = lm2;
}
*start = nullptr;
Expand All @@ -190,7 +193,7 @@ static bool reload_table() {
uint8_t* buffer = nullptr;
size_t buflen = 1024;
for (;;) {
buffer = (uint8_t*) ::realloc(buffer, buflen);
buffer = (uint8_t*) permit_forbidden_function::realloc(buffer, buflen);
if (loadquery(L_GETINFO, buffer, buflen) == -1) {
if (errno == ENOMEM) {
buflen *= 2;
Expand All @@ -210,7 +213,7 @@ static bool reload_table() {

for (;;) {

loaded_module_t* lm = (loaded_module_t*) ::malloc(sizeof(loaded_module_t));
loaded_module_t* lm = (loaded_module_t*) permit_forbidden_function::malloc(sizeof(loaded_module_t));
if (!lm) {
log_warning(os)("OOM.");
goto cleanup;
Expand All @@ -226,7 +229,7 @@ static bool reload_table() {
lm->path = g_stringlist.add(ldi->ldinfo_filename);
if (!lm->path) {
log_warning(os)("OOM.");
free(lm);
permit_forbidden_function::free(lm);
goto cleanup;
}

Expand All @@ -248,7 +251,7 @@ static bool reload_table() {
lm->member = g_stringlist.add(p_mbr_name);
if (!lm->member) {
log_warning(os)("OOM.");
free(lm);
permit_forbidden_function::free(lm);
goto cleanup;
}
} else {
Expand Down Expand Up @@ -296,7 +299,7 @@ static bool reload_table() {
free_entry_list(&new_list);
}

::free(buffer);
permit_forbidden_function::free(buffer);

return rc;

Expand Down
9 changes: 5 additions & 4 deletions src/hotspot/os/aix/os_aix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include "utilities/defaultStream.hpp"
#include "utilities/events.hpp"
#include "utilities/growableArray.hpp"
#include "utilities/permitForbiddenFunctions.hpp"
#include "utilities/vmError.hpp"
#if INCLUDE_JFR
#include "jfr/support/jfrNativeLibraryLoadEvent.hpp"
Expand Down Expand Up @@ -364,9 +365,9 @@ static void query_multipage_support() {
// or by environment variable LDR_CNTRL (suboption DATAPSIZE). If none is given,
// default should be 4K.
{
void* p = ::malloc(16*M);
void* p = permit_forbidden_function::malloc(16*M);
g_multipage_support.datapsize = os::Aix::query_pagesize(p);
::free(p);
permit_forbidden_function::free(p);
}

// Query default shm page size (LDR_CNTRL SHMPSIZE).
Expand Down Expand Up @@ -1406,7 +1407,7 @@ static struct {
} vmem;

static void vmembk_add(char* addr, size_t size, size_t pagesize, int type) {
vmembk_t* p = (vmembk_t*) ::malloc(sizeof(vmembk_t));
vmembk_t* p = (vmembk_t*) permit_forbidden_function::malloc(sizeof(vmembk_t));
assert0(p);
if (p) {
MiscUtils::AutoCritSect lck(&vmem.cs);
Expand Down Expand Up @@ -1435,7 +1436,7 @@ static void vmembk_remove(vmembk_t* p0) {
for (vmembk_t** pp = &(vmem.first); *pp; pp = &((*pp)->next)) {
if (*pp == p0) {
*pp = p0->next;
::free(p0);
permit_forbidden_function::free(p0);
return;
}
}
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 @@ -1082,7 +1082,7 @@ void* Aix_dlopen(const char* filename, int Flags, int *eno, const char** error_r
if (g_handletable_used == max_handletable) {
// No place in array anymore; increase array.
unsigned new_max = MAX2(max_handletable * 2, init_num_handles);
struct handletableentry* new_tab = (struct handletableentry*)::realloc(p_handletable, new_max * sizeof(struct handletableentry));
struct handletableentry* new_tab = (struct handletableentry*) permit_forbidden_function::realloc(p_handletable, new_max * sizeof(struct handletableentry));
assert(new_tab != nullptr, "no more memory for handletable");
if (new_tab == nullptr) {
*error_report = "dlopen: no more memory for handletable";
Expand Down

0 comments on commit b774f14

Please sign in to comment.