Skip to content
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

Build error: "storing the address of local variable" in runtime/rastrace/trcmain.c #20171

Open
knn-k opened this issue Sep 17, 2024 · 2 comments · May be fixed by #20172
Open

Build error: "storing the address of local variable" in runtime/rastrace/trcmain.c #20171

knn-k opened this issue Sep 17, 2024 · 2 comments · May be fixed by #20172

Comments

@knn-k
Copy link
Contributor

knn-k commented Sep 17, 2024

Building OpenJ9 Java 17 with GCC 13.2.0 on Ubuntu 24.04.1 generates the following error:

/home/openj9/openj9-openjdk-jdk17/openj9/runtime/rastrace/trcmain.c:1045:14: error: storing the address of local variable 'tempThr' in '*thr' [-Werror=dangling-pointer=]
 1045 |         *thr = &tempThr;
      |         ~~~~~^~~~~~~~~~
/home/openj9/openj9-openjdk-jdk17/openj9/runtime/rastrace/trcmain.c:1033:23: note: 'tempThr' declared here
 1033 |         UtThreadData  tempThr;
      |                       ^~~~~~~
/home/openj9/openj9-openjdk-jdk17/openj9/runtime/rastrace/trcmain.c:1026:32: note: 'thr' declared here
 1026 | initializeTrace(UtThreadData **thr, void **gbl,
      |                 ~~~~~~~~~~~~~~~^~~

*thr = &tempThr;

tempThr is a local variable in initializeTrace(). thr is the first argument for initializeTrace(). The address of tempThr is used by J9VMDllMain() in trcengine.c, the caller of initializeTrace().

rc = initializeTrace(tempThr, tempGbl, (const char **)opts, vm->omrVM, (const char **)ignore, &languageIntf);

The memory region for tempThr in the stack can be overwritten by other functions.
I think J9VMDllMain() should prepare the memory region for UtThreadData, as J9VMDllMain() seems to be the only caller of initializeTrace().

@knn-k
Copy link
Contributor Author

knn-k commented Sep 17, 2024

Another build error with GCC 13.2.0: #20170

knn-k added a commit to knn-k/openj9 that referenced this issue Sep 17, 2024
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>
@knn-k
Copy link
Contributor Author

knn-k commented Sep 17, 2024

I opened a draft PR: #20172

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant