mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8004495: [parfait] False positive Buffer overflow in hotspot/src/os/linux/vm/os_linux.cpp
Delete the questionable source code because it is for no-longer supported versions of Linux. Reviewed-by: mikael, coleenp
This commit is contained in:
parent
99fa0d1e99
commit
2d47fd6658
1 changed files with 2 additions and 26 deletions
|
@ -4743,49 +4743,26 @@ jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
||||||
//
|
//
|
||||||
|
|
||||||
static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
||||||
static bool proc_pid_cpu_avail = true;
|
|
||||||
static bool proc_task_unchecked = true;
|
static bool proc_task_unchecked = true;
|
||||||
static const char *proc_stat_path = "/proc/%d/stat";
|
static const char *proc_stat_path = "/proc/%d/stat";
|
||||||
pid_t tid = thread->osthread()->thread_id();
|
pid_t tid = thread->osthread()->thread_id();
|
||||||
int i;
|
|
||||||
char *s;
|
char *s;
|
||||||
char stat[2048];
|
char stat[2048];
|
||||||
int statlen;
|
int statlen;
|
||||||
char proc_name[64];
|
char proc_name[64];
|
||||||
int count;
|
int count;
|
||||||
long sys_time, user_time;
|
long sys_time, user_time;
|
||||||
char string[64];
|
|
||||||
char cdummy;
|
char cdummy;
|
||||||
int idummy;
|
int idummy;
|
||||||
long ldummy;
|
long ldummy;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
// We first try accessing /proc/<pid>/cpu since this is faster to
|
|
||||||
// process. If this file is not present (linux kernels 2.5 and above)
|
|
||||||
// then we open /proc/<pid>/stat.
|
|
||||||
if ( proc_pid_cpu_avail ) {
|
|
||||||
sprintf(proc_name, "/proc/%d/cpu", tid);
|
|
||||||
fp = fopen(proc_name, "r");
|
|
||||||
if ( fp != NULL ) {
|
|
||||||
count = fscanf( fp, "%s %lu %lu\n", string, &user_time, &sys_time);
|
|
||||||
fclose(fp);
|
|
||||||
if ( count != 3 ) return -1;
|
|
||||||
|
|
||||||
if (user_sys_cpu_time) {
|
|
||||||
return ((jlong)sys_time + (jlong)user_time) * (1000000000 / clock_tics_per_sec);
|
|
||||||
} else {
|
|
||||||
return (jlong)user_time * (1000000000 / clock_tics_per_sec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else proc_pid_cpu_avail = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The /proc/<tid>/stat aggregates per-process usage on
|
// The /proc/<tid>/stat aggregates per-process usage on
|
||||||
// new Linux kernels 2.6+ where NPTL is supported.
|
// new Linux kernels 2.6+ where NPTL is supported.
|
||||||
// The /proc/self/task/<tid>/stat still has the per-thread usage.
|
// The /proc/self/task/<tid>/stat still has the per-thread usage.
|
||||||
// See bug 6328462.
|
// See bug 6328462.
|
||||||
// There can be no directory /proc/self/task on kernels 2.4 with NPTL
|
// There possibly can be cases where there is no directory
|
||||||
// and possibly in some other cases, so we check its availability.
|
// /proc/self/task, so we check its availability.
|
||||||
if (proc_task_unchecked && os::Linux::is_NPTL()) {
|
if (proc_task_unchecked && os::Linux::is_NPTL()) {
|
||||||
// This is executed only once
|
// This is executed only once
|
||||||
proc_task_unchecked = false;
|
proc_task_unchecked = false;
|
||||||
|
@ -4810,7 +4787,6 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
|
||||||
// We don't really need to know the command string, just find the last
|
// We don't really need to know the command string, just find the last
|
||||||
// occurrence of ")" and then start parsing from there. See bug 4726580.
|
// occurrence of ")" and then start parsing from there. See bug 4726580.
|
||||||
s = strrchr(stat, ')');
|
s = strrchr(stat, ')');
|
||||||
i = 0;
|
|
||||||
if (s == NULL ) return -1;
|
if (s == NULL ) return -1;
|
||||||
|
|
||||||
// Skip blank chars
|
// Skip blank chars
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue