Skip to content

Commit

Permalink
Implemented feedback and make sure periodic tasks intervals are sane.
Browse files Browse the repository at this point in the history
  • Loading branch information
schmelter-sap committed Jan 25, 2024
1 parent 53f2381 commit 4e0919a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/hotspot/os/posix/malloctrace/mallocTrace2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ static uint64_t parse_timespan_part(char const* start, char const* end, char con
return 0;
}

if (((size_t) (end - start)) >= sizeof(buf) - 1) {
size_t size = (size_t) (end - start);

if (size >= sizeof(buf)) {
*error = "time too long";
return 0;
}

memcpy(buf, start, end - start);
buf[end - start] = '\0';
memcpy(buf, start, size);
buf[size] = '\0';

char* found_end;
uint64_t result = (uint64_t) strtoull(buf, &found_end, 10);
Expand Down Expand Up @@ -2395,7 +2397,7 @@ class MallocTraceDumpPeriodicTask : public PeriodicTask {

public:
MallocTraceDumpPeriodicTask(uint64_t delay) :
PeriodicTask(1000 * delay),
PeriodicTask(MIN2((uint64_t) 2000000000, 1000 * delay)),
_left(MallocTraceDumpCount - 1) {
}

Expand All @@ -2415,7 +2417,7 @@ class MallocTraceDumpInitialTask : public PeriodicTask {

public:
MallocTraceDumpInitialTask(uint64_t delay) :
PeriodicTask(1000 * delay) {
PeriodicTask(MIN2((uint64_t) 2000000000, 1000 * delay)) {
}

virtual void task();
Expand Down

0 comments on commit 4e0919a

Please sign in to comment.