-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
None
SonarCloud complains this is a dodgy access:
bool JfrCPUSamplerThread::create_timer_for_thread(JavaThread* thread, timer_t& timerid) {
struct sigevent sev;
sev.sigev_notify = SIGEV_THREAD_ID;
sev.sigev_signo = SIG;
sev.sigev_value.sival_ptr = nullptr;
((int*)&sev.sigev_notify)[1] = thread->osthread()->thread_id(); // <--- here
I suspect the intent is to reach for platform-specific _tid field there. The current expression seems to hit the right spot:
typedef struct sigevent {
__sigval_t sigev_value;
int sigev_signo;
int sigev_notify;
union {
int _pad[__SIGEV_PAD_SIZE];
__pid_t _tid;
struct {
void (*_function) (__sigval_t); /* Function to start. */
pthread_attr_t *_attribute; /* Thread attributes. */
} _sigev_thread;
} _sigev_un;
} sigevent_t;
...but I do not think it is 100% portable. Maybe it is possible to somehow access `sev._sigev_un._tid` directly without breaking too many builds.
bool JfrCPUSamplerThread::create_timer_for_thread(JavaThread* thread, timer_t& timerid) {
struct sigevent sev;
sev.sigev_notify = SIGEV_THREAD_ID;
sev.sigev_signo = SIG;
sev.sigev_value.sival_ptr = nullptr;
((int*)&sev.sigev_notify)[1] = thread->osthread()->thread_id(); // <--- here
I suspect the intent is to reach for platform-specific _tid field there. The current expression seems to hit the right spot:
typedef struct sigevent {
__sigval_t sigev_value;
int sigev_signo;
int sigev_notify;
union {
int _pad[__SIGEV_PAD_SIZE];
__pid_t _tid;
struct {
void (*_function) (__sigval_t); /* Function to start. */
pthread_attr_t *_attribute; /* Thread attributes. */
} _sigev_thread;
} _sigev_un;
} sigevent_t;
...but I do not think it is 100% portable. Maybe it is possible to somehow access `sev._sigev_un._tid` directly without breaking too many builds.
- caused by
-
JDK-8358666 [REDO] Implement JEP 509: JFR CPU-Time Profiling
-
- Resolved
-