-
Notifications
You must be signed in to change notification settings - Fork 720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid stringop-overflow errors #10293
base: master
Are you sure you want to change the base?
Conversation
error: '__builtin_strncpy' writing 512 bytes into a region of size 1 overflows the destination Signed-off-by: Keith W. Campbell <keithc@ca.ibm.com>
Tested by @knn-k - see #10278 (comment). |
#4486 is the original issue with trclog.c and AArch64. |
jenkins compile all jdk11 |
* target for strcpy, etc.: we want to avoid warnings due to the | ||
* apparent lack of space (we've made sure there's enough room). | ||
*/ | ||
recordThreadName = offsetof(UtTraceRecord, threadName) + (char *)(void *)&trcBuf->record; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to cast twice here? I don't think (void *)
is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps not, but I think it's safer with the extra cast as it should make it clear to the compiler that there's no relationship between the pointer &trcBuf->record
and the result of the casts.
Consider an analogy with Java: You'll get a compile error trying to cast a String
to an Integer
, but you can write (Integer)(Object)"oops"
which compiles just fine (though you'll get a ClassCastException
at runtime). The cast to Object
is comparable to the cast to void *
(and there's no exception in C).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect this particular part of the change will be unnecessary once eclipse/omr#5444 is merged.
this is not a correct solution. see #10244 (comment), #10244 (comment), #10299 (comment) |
Please explain this assertion. |
Can one of the admins verify this patch? |
Rework code that sets thread name in trace buffer to avoid compiler errors, e.g.: