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

New warnings when compiling Julia with GCC 12 #45400

Closed
giordano opened this issue May 20, 2022 · 7 comments
Closed

New warnings when compiling Julia with GCC 12 #45400

giordano opened this issue May 20, 2022 · 7 comments
Labels
building Build system, or building Julia or its dependencies

Comments

@giordano
Copy link
Contributor

giordano commented May 20, 2022

Since I upgraded to GCC 12, I'm getting some new warnings when compiling Julia.

/home/mose/repo/julia/src/init.c: In function 'jl_init_stack_limits':
/home/mose/repo/julia/src/init.c:75:19: warning: storing the address of local variable 'stacksize' in '*stack_hi' [-Wdangling-pointer=]
   75 |         *stack_hi = (void*)&stacksize;
      |         ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/home/mose/repo/julia/src/init.c:71:16: note: 'stacksize' declared here
   71 |         size_t stacksize;
      |                ^~~~~~~~~
/home/mose/repo/julia/src/init.c:71:16: note: 'stack_hi' declared here
/home/mose/repo/julia/src/init.c:105:15: warning: storing the address of local variable 'stacksize' in '*stack_lo' [-Wdangling-pointer=]
  105 |     *stack_lo = (void*)((char*)*stack_hi - stacksize);
      |     ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mose/repo/julia/src/init.c:103:12: note: 'stacksize' declared here
  103 |     size_t stacksize = rl.rlim_cur;
      |            ^~~~~~~~~
/home/mose/repo/julia/src/init.c:103:12: note: 'stack_lo' declared here
/home/mose/repo/julia/src/init.c: In function 'julia_init':
/home/mose/repo/julia/src/init.c:719:21: warning: using a dangling pointer to 'stacksize' [-Wdangling-pointer=]
  719 |     jl_task_t *ct = jl_init_root_task(ptls, stack_lo, stack_hi);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mose/repo/julia/src/init.c:103:12: note: 'stacksize' declared here
  103 |     size_t stacksize = rl.rlim_cur;
      |            ^~~~~~~~~

My understanding is that these dangling pointers are there pretty much on purpose. If that's the case, we should use either a pragma or a compiler flag to silence them.

/home/mose/repo/julia/src/gc.c: In function 'gc_mark_stack_resize':
/home/mose/repo/julia/src/gc.c:1722:89: warning: pointer 'old_data' may be used after 'realloc' [-Wuse-after-free]
 1722 |     sp->data = (jl_gc_mark_data_t *)(((char*)sp->data) + (((char*)gc_cache->data_stack) - ((char*)old_data)));
      |                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /home/mose/repo/julia/src/support/libsupport.h:10,
                 from /home/mose/repo/julia/src/julia.h:14,
                 from /home/mose/repo/julia/src/gc.h:16,
                 from /home/mose/repo/julia/src/gc.c:3:
In function 'realloc_s',
    inlined from 'gc_mark_stack_resize' at /home/mose/repo/julia/src/gc.c:1721:49:
/home/mose/repo/julia/src/support/dtypes.h:356:9: note: call to 'realloc' here
  356 |     p = realloc(p, sz == 0 ? 1 : sz);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mose/repo/julia/src/gc.c: In function 'gc_mark_stack_resize':
/home/mose/repo/julia/src/gc.c:1726:37: warning: pointer 'pc_stack' may be used after 'realloc' [-Wuse-after-free]
 1726 |     sp->pc = sp->pc_start + (sp->pc - pc_stack);
      |                                     ^
In function 'realloc_s',
    inlined from 'gc_mark_stack_resize' at /home/mose/repo/julia/src/gc.c:1724:49:
/home/mose/repo/julia/src/support/dtypes.h:356:9: note: call to 'realloc' here
  356 |     p = realloc(p, sz == 0 ? 1 : sz);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

This sounds like something that should be fixed? (tentatively pinging @chflood since this is in the GC)

In file included from /home/mose/repo/julia/usr/include/llvm/Bitcode/BitcodeWriter.h:17,
                 from /home/mose/repo/julia/src/aotcompile.cpp:47:
/home/mose/repo/julia/usr/include/llvm/IR/ModuleSummaryIndex.h: In constructor 'llvm::ModuleSummaryIndex::ModuleSummaryIndex(bool, bool)':
/home/mose/repo/julia/usr/include/llvm/IR/ModuleSummaryIndex.h:1116:73: warning: member 'llvm::ModuleSummaryIndex::Alloc' is used uninitialized [-Wuninitialized]
 1116 |       : HaveGVs(HaveGVs), EnableSplitLTOUnit(EnableSplitLTOUnit), Saver(Alloc),
      |                                                                         ^~~~~
    [...]
In file included from /home/mose/repo/julia/usr/include/llvm/Bitcode/BitcodeWriter.h:17,
                 from /home/mose/repo/julia/src/jitlayers.cpp:21:
/home/mose/repo/julia/usr/include/llvm/IR/ModuleSummaryIndex.h: In constructor 'llvm::ModuleSummaryIndex::ModuleSummaryIndex(bool, bool)':
/home/mose/repo/julia/usr/include/llvm/IR/ModuleSummaryIndex.h:1116:73: warning: member 'llvm::ModuleSummaryIndex::Alloc' is used uninitialized [-Wuninitialized]
 1116 |       : HaveGVs(HaveGVs), EnableSplitLTOUnit(EnableSplitLTOUnit), Saver(Alloc),
      |                                                                         ^~~~~
    [...]
In file included from /home/mose/repo/julia/usr/include/llvm/CodeGen/MachineInstr.h:19,
                 from /home/mose/repo/julia/usr/include/llvm/CodeGen/MachineBasicBlock.h:20,
                 from /home/mose/repo/julia/usr/include/llvm/CodeGen/MachineFunction.h:28,
                 from /home/mose/repo/julia/usr/include/llvm/CodeGen/MachineFunctionPass.h:21,
                 from /home/mose/repo/julia/usr/include/llvm/CodeGen/AsmPrinter.h:22,
                 from /home/mose/repo/julia/src/disasm.cpp:104:
/home/mose/repo/julia/usr/include/llvm/ADT/PointerSumType.h: In static member function 'static llvm::DenseMapInfo<llvm::PointerSumType<TagT, MemberTs ...> >::SumType llvm::DenseMapInfo<llvm::PointerSumType<TagT, MemberTs ...> >::getEmptyKey()':
/home/mose/repo/julia/usr/include/llvm/ADT/PointerSumType.h:275:21: warning: expected 'template' keyword before dependent template name [-Wmissing-template-keyword]
  275 |     return SumType::create<SomeTag>(SomePointerInfo::getEmptyKey());
      |                     ^~~~~~
/home/mose/repo/julia/usr/include/llvm/ADT/PointerSumType.h: In static member function 'static llvm::DenseMapInfo<llvm::PointerSumType<TagT, MemberTs ...> >::SumType llvm::DenseMapInfo<llvm::PointerSumType<TagT, MemberTs ...> >::getTombstoneKey()':
/home/mose/repo/julia/usr/include/llvm/ADT/PointerSumType.h:279:21: warning: expected 'template' keyword before dependent template name [-Wmissing-template-keyword]
  279 |     return SumType::create<SomeTag>(SomePointerInfo::getTombstoneKey());
      |                     ^~~~~~
    [...]
In file included from /home/mose/repo/julia/usr/include/llvm/Bitcode/BitcodeWriter.h:17,
                 from /home/mose/repo/julia/src/codegen.cpp:65:
/home/mose/repo/julia/usr/include/llvm/IR/ModuleSummaryIndex.h: In constructor 'llvm::ModuleSummaryIndex::ModuleSummaryIndex(bool, bool)':
/home/mose/repo/julia/usr/include/llvm/IR/ModuleSummaryIndex.h:1116:73: warning: member 'llvm::ModuleSummaryIndex::Alloc' is used uninitialized [-Wuninitialized]
 1116 |       : HaveGVs(HaveGVs), EnableSplitLTOUnit(EnableSplitLTOUnit), Saver(Alloc),
      |                                                                         ^~~~~

These are from LLVM, so probably little we can do about directly (Edit 1: first warnings fixed by llvm/llvm-project@8e066b8. Edit 2: more LLVM warnings fixed by llvm/llvm-project@1d9086b).

@giordano giordano added the building Build system, or building Julia or its dependencies label May 20, 2022
@ViralBShah ViralBShah added the upstream The issue is with an upstream dependency, e.g. LLVM label May 22, 2022
@giordano
Copy link
Contributor Author

giordano commented Jun 18, 2022

Not a new warning in GCC 12, but aarch64-linux-gnu builds in CI show this warning:

/cache/build/default-armageddon-0/julialang/julia-master/src/stackwalk.c: In function 'jl_rec_backtrace':
/cache/build/default-armageddon-0/julialang/julia-master/src/stackwalk.c:903:22: warning: initialization of 'mcontext_t *' {aka 'struct sigcontext *'} from incompatible pointer type 'struct unw_sigcontext *' [-Wincompatible-pointer-types]
  903 |     mcontext_t *mc = &c.uc_mcontext;
      |                      ^

Introduced by #45110.

@giordano
Copy link
Contributor Author

But from the same PR, with GCC 11 on aarch64-linux-gnu I get many more warnings:

/home/mose/repo/julia/src/stackwalk.c: In function 'jl_rec_backtrace':
/home/mose/repo/julia/src/stackwalk.c:903:22: warning: initialization of 'mcontext_t *' from incompatible pointer type 'struct unw_sigcontext *' [-Wincompatible-pointer-types]
  903 |     mcontext_t *mc = &c.uc_mcontext;
      |                      ^
/home/mose/repo/julia/src/stackwalk.c:960:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  960 |     mc->regs[19] = (*mctx)[0];
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:961:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  961 |     mc->regs[20] = (*mctx)[1];
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:962:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  962 |     mc->regs[21] = (*mctx)[2];
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:963:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  963 |     mc->regs[22] = (*mctx)[3];
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:964:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  964 |     mc->regs[23] = (*mctx)[4];
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:965:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  965 |     mc->regs[24] = (*mctx)[5];
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:966:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  966 |     mc->regs[25] = (*mctx)[6];
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:967:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  967 |     mc->regs[26] = (*mctx)[7];
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:968:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  968 |     mc->regs[27] = (*mctx)[8];
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:969:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  969 |     mc->regs[28] = (*mctx)[9];
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:970:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  970 |     mc->regs[29] = (*mctx)[10]; // aka fp
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:971:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  971 |     mc->regs[30] = (*mctx)[11]; // aka lr
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:973:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  973 |     mc->sp = (*mctx)[13];
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:974:9: warning: array subscript 'unw_fpsimd_context_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  974 |     mcfp->vregs[7] = (*mctx)[14]; // aka d8
      |         ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:975:9: warning: array subscript 'unw_fpsimd_context_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  975 |     mcfp->vregs[8] = (*mctx)[15]; // aka d9
      |         ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:976:9: warning: array subscript 'unw_fpsimd_context_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  976 |     mcfp->vregs[9] = (*mctx)[16]; // aka d10
      |         ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:977:9: warning: array subscript 'unw_fpsimd_context_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  977 |     mcfp->vregs[10] = (*mctx)[17]; // aka d11
      |         ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:978:9: warning: array subscript 'unw_fpsimd_context_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  978 |     mcfp->vregs[11] = (*mctx)[18]; // aka d12
      |         ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:979:9: warning: array subscript 'unw_fpsimd_context_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  979 |     mcfp->vregs[12] = (*mctx)[19]; // aka d13
      |         ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:980:9: warning: array subscript 'unw_fpsimd_context_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  980 |     mcfp->vregs[13] = (*mctx)[20]; // aka d14
      |         ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:981:9: warning: array subscript 'unw_fpsimd_context_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  981 |     mcfp->vregs[14] = (*mctx)[21]; // aka d15
      |         ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:983:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  983 |     mc->sp = ptr_demangle(mc->sp);
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:984:35: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  984 |     mc->regs[30] = ptr_demangle(mc->regs[30]);
      |                                   ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:984:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  984 |     mc->regs[30] = ptr_demangle(mc->regs[30]);
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^
/home/mose/repo/julia/src/stackwalk.c:985:7: warning: array subscript 'mcontext_t[0]' is partly outside array bounds of 'bt_context_t[1]' {aka 'unw_tdep_context_t[1]'} [-Warray-bounds]
  985 |     mc->pc = mc->regs[30];
      |       ^~
/home/mose/repo/julia/src/stackwalk.c:899:18: note: while referencing 'c'
  899 |     bt_context_t c;
      |                  ^

CC: @vtjnash

@giordano

This comment was marked as resolved.

@giordano

This comment was marked as outdated.

@Moelf

This comment was marked as outdated.

@gbaraldi

This comment was marked as outdated.

@giordano giordano removed the upstream The issue is with an upstream dependency, e.g. LLVM label Aug 16, 2024
@giordano
Copy link
Contributor Author

On 0a26e90 julia builds cleanly on x86_64-linux-gnu with gcc 12.3. There are still some warnings on aarch64-linux-gnu, but I think it's time to close this ticket because it served its purpose, maybe I'll open something more specific later for aarch64-linux-gnu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
building Build system, or building Julia or its dependencies
Projects
None yet
Development

No branches or pull requests

4 participants