-
Notifications
You must be signed in to change notification settings - Fork 77
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
error: storing the address of local variable 'stackOut' in '*stackOut.0_1' [-Werror=dangling-pointer=] #256
Comments
Many thanks for your report. Can you tell us anything more about how what you're working on uses the MPS? We currently build and test the MPS on Ubuntu 22, which is currently on GCC 11.3.0. We'll investigate the GCC 13 build. If you are not modifying the MPS itself, you can build it for your project by following 2.3. Compiling the MPS for your project https://memory-pool-system.readthedocs.io/en/version-1.118/guide/build.html#compiling-the-mps-for-your-project. This will not produce warnings as errors. If you're developing the MPS, you can work around this problem locally by modifying code/gc.gmk to suppress this warning, by adding something like -Wno-error=dangling-pointer to CFLAGSCOMPILER. If you are integrating the MPS with Ruby (or have done so), we'd very much like to hear about it. |
I run Ubuntu 13 minimal (from ubuntu-23.04-desktop-amd64.iso) in a VM and installed the default gcc (gcc-12.2.0-1ubuntu1) and gcc-13 (gcc-13-20230320-1ubuntu1) with apt:
Both fail with the same warning error:
This isn't the same as observed above, but it indicated we have some work to do to ensure we build cleanly under GCC 12 and 13 both. |
In GitHub Actions, |
diff --git a/code/ss.c b/code/ss.c
index ce08810..2dea149 100644
--- a/code/ss.c
+++ b/code/ss.c
@@ -19,6 +19,7 @@
* stackCold).
*/
+#include <stdlib.h>
#include "mpm.h"
SRCID(ss, "$Id$");
@@ -35,7 +36,8 @@ SRCID(ss, "$Id$");
ATTRIBUTE_NOINLINE
void StackHot(void **stackOut)
{
- *stackOut = &stackOut;
+ void *newStackOut = malloc(sizeof(void *));
+ *stackOut = newStackOut;
} After applying the above patch (not sure it is correct), I retried to build, also failed with the similar error. lii6gc: lii6gc/hot/abqtest.o
lii6gc: lii6gc/hot/mps.o
In file included from mps.c:98:
In function ‘mps_lib_memcpy’,
inlined from ‘VMArenaCreate’ at arenavm.c:683:9:
mpsliban.c:105:10: error: ‘vmParams’ may be used uninitialized [-Werror=maybe-uninitialized]
105 | return memcpy(s1, s2, n);
| ^~~~~~~~~~~~~~~~~
In file included from mps.c:35:
arenavm.c: In function ‘VMArenaCreate’:
arenavm.c:603:8: note: ‘vmParams’ declared here
603 | char vmParams[VMParamSize];
| ^~~~~~~~
cc1: all warnings being treated as errors |
So I think we can extend the matrix here mps/.github/workflows/build-and-test.yml Lines 36 to 38 in 554513b
|
Nice try! :) Just for the record, that patch will break the stack scanning in the MPS. The purpose is to get an address at the "hot" end of the stack by taking the address of an argument (spilled local variable). It's a weird thing to do and I'm not surprised the compiler has got around to noticing it. It's an attempt to avoid the need for assembler code to get the stack pointer. |
Unfortunately, the GCC 12 available does not provoke this warning. On ubuntu-latest (see https://github.com/Ravenbrook/mps/actions/runs/5635102961/job/15265698554?pr=257 ):
Whereas on ubuntu-23.04-desktop-amd64.iso (via https://releases.ubuntu.com/23.04/ubuntu-23.04-desktop-amd64.iso.torrent ):
So I think this warning was introduced in GCC 12.2. |
@topazus 8e117ae (in #257 ) resolves warning on GCC 12.2.0 and GCC 13.0.1, passing |
I opened #258 to add Fedora CI which will reproduce the error. The build log of github workflow: https://github.com/topazus/mps/actions/runs/5636841949/job/15269323018
For the time being, we may add the |
Thank you. We'll consider integrating this into our usual CI in order to get early warnings of... warnings. |
I found the Fedora nightly compose finder which provided Fedora-Everything-netinst-x86_64-Rawhide-20230724.n.0.iso from which I was able to create a VM. The GCC version is 13.1.1. I was able to reproduce the error in the original post above. So I suspect that the warning was introduced in GCC 13.1, since it is not present in 13.0. I'm investigating the proper fix. |
Please consider that unless you are developing the MPS we recommend you do not use configure+make. See Compiling the MPS for your project. If this is hard to do, we'd like to know more, so that we can provide a more convenient integration. |
A quick reproduction using an LXD container (in my case on Ubuntu 22):
The version reported by GCC is "gcc (Ubuntu 13.2.0-3ubuntu1) 13.2.0". |
I try to compile mps 1.118.0 with GCC 13 on Fedora 39, but I occured the build error.
The text was updated successfully, but these errors were encountered: