Skip to content

Commit

Permalink
Fix "storing the address of local variable" in trcmain.c
Browse files Browse the repository at this point in the history
This commit stops storing the address of a local variable, to fix a
build error with runtime/rastrace/trcmain.c.

Fixes: eclipse-openj9#20171

Signed-off-by: KONNO Kazuhiro <konno@jp.ibm.com>
  • Loading branch information
knn-k committed Sep 17, 2024
1 parent 0985ff3 commit 4813a2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 2 additions & 1 deletion runtime/rastrace/trcengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ J9VMDllMain(J9JavaVM *vm, IDATA stage, void *reserved)
char *opts[UT_MAX_OPTS] = {0};
int i = 0;
UtThreadData **tempThr = NULL;
UtThreadData thrData;
J9VMThread *thr = NULL;
RasGlobalStorage *tempRasGbl = (RasGlobalStorage *)vm->j9rasGlobalStorage;
void **tempGbl = NULL;
Expand Down Expand Up @@ -333,6 +334,7 @@ J9VMDllMain(J9JavaVM *vm, IDATA stage, void *reserved)
* Find UTE thread slot inside VM thread structure
*/
tempThr = UT_THREAD_FROM_VM_THREAD(vm->mainThread);
*tempThr = &thrData;
tempGbl = &tempRasGbl->utGlobalData;

/* Add Java trace trigger types to the default OMR set */
Expand Down Expand Up @@ -463,7 +465,6 @@ J9VMDllMain(J9JavaVM *vm, IDATA stage, void *reserved)
break;

case VM_INITIALIZATION_COMPLETE:
tempThr = UT_THREAD_FROM_VM_THREAD(vm->mainThread);
{
/* Force loading of the Trace class. See defect 162723, this is required because of some nuance
* in the early initialization of DB/2 (which uses the Trace class).
Expand Down
9 changes: 3 additions & 6 deletions runtime/rastrace/trcmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,11 +1026,10 @@ omr_error_t
initializeTrace(UtThreadData **thr, void **gbl,
const char **opts, const OMR_VM *vm,
const char ** ignore, const OMRTraceLanguageInterface *languageIntf)

{
omr_error_t rc = OMR_ERROR_NONE;
int i;
UtThreadData tempThr;
UtThreadData *tempThr = *thr;
UtGlobalData tempGbl;
UtGlobalData *newGbl;
qQueue *outputQueue = NULL;
Expand All @@ -1039,10 +1038,8 @@ initializeTrace(UtThreadData **thr, void **gbl,
/*
* Bootstrap UtThreadData first using stack variable (in case we call utcFprintf below)
*/
memset(&tempThr, 0, sizeof(UtThreadData));
initHeader(&tempThr.header, UT_THREAD_DATA_NAME, sizeof(UtThreadData));

*thr = &tempThr;
memset(tempThr, 0, sizeof(UtThreadData));
initHeader(&(tempThr->header), UT_THREAD_DATA_NAME, sizeof(UtThreadData));

if (utGlobal != NULL){
if (UT_GLOBAL(traceEnabled) == TRUE){
Expand Down

0 comments on commit 4813a2d

Please sign in to comment.