Closed Bug 1817858 Opened 3 years ago Closed 2 years ago

C-C TB gcc-12 compilation issue. : error: ‘this’ pointer is null [-Werror=nonnull] 65 | ((morkNext*)0)->ZapOldNext((morkEnv*)0, (nsIMdbHeap*)0);

Categories

(MailNews Core :: Composition, defect)

x86_64
Linux
defect

Tracking

(Not tracked)

RESOLVED FIXED
125 Branch

People

(Reporter: ishikawa, Assigned: ishikawa)

Details

Attachments

(1 external file, 1 obsolete file)

I am compiling C-C TB locallyg using GCC under Debian GNU/Linux on my local PC.

Tring to compile C-C TB revealed a few issues of GCC-12 and this is one of them.

I am attaching the log of the failure below.
I think the compilation error can be ignored by -Wno-error=nonnull, but
disabling error warning caused by dubious construct is not desirable IMHO.
The log:


ishikawa@ip030:/NREF-COMM-CENTRAL/mozilla/comm$ bash -vx /tmp/t99.sh
:
+ :
#
pushd /NEW-SSD/moz-obj-dir/objdir-tb3/comm/mailnews/db/mork/
+ pushd /NEW-SSD/moz-obj-dir/objdir-tb3/comm/mailnews/db/mork/
/NEW-SSD/moz-obj-dir/objdir-tb3/comm/mailnews/db/mork /NREF-COMM-CENTRAL/mozilla/comm

/usr/bin/ccache /usr/bin/g++-12 --sysroot /home/ishikawa/.mozbuild/sysroot-x86_64-linux-gnu -std=gnu++17 -isystem /home/ishikawa/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/c++/7.5.0 -isystem /home/ishikawa/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/x86_64-linux-gnu/c++/7.5.0 -isystem /home/ishikawa/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/x86_64-linux-gnu -isystem /home/ishikawa/.mozbuild/sysroot-x86_64-linux-gnu/usr/include -o morkStream.o -c  -I/NEW-SSD/moz-obj-dir/objdir-tb3/dist/stl_wrappers -I/NEW-SSD/moz-obj-dir/objdir-tb3/dist/system_wrappers -include /NEW-SSD/NREF-COMM-CENTRAL/mozilla/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -DDEBUG=1 -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DSTATIC_EXPORTABLE_JS_API -I/NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/mailnews/db/mork -I/NEW-SSD/moz-obj-dir/objdir-tb3/comm/mailnews/db/mork -I/NEW-SSD/moz-obj-dir/objdir-tb3/dist/include -I/NEW-SSD/moz-obj-dir/objdir-tb3/dist/include/nspr -I/NEW-SSD/moz-obj-dir/objdir-tb3/dist/include/nss -DMOZILLA_CLIENT -include /NEW-SSD/moz-obj-dir/objdir-tb3/mozilla-config.h -fno-sized-deallocation -fno-aligned-new -ldl -fno-builtin-strlen -Dfdatasync=fdatasync -DDEBUG_4GB_CHECK -DUSEHELGRIND=1 -DUSEVALGRIND=1 -DDEBUG -g -Werror=sign-compare -Werror=unused-result -Werror=unused-variable -Werror=format -fuse-ld=gold -fno-exceptions -fPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -g -g -Og -fvar-tracking -gdwarf-4 -fvar-tracking-assignments -freorder-blocks -fno-omit-frame-pointer -funwind-tables -Wall -Wempty-body -Wignored-qualifiers -Wpointer-arith -Wsign-compare -Wtype-limits -Wunreachable-code -Wno-invalid-offsetof -Wc++2a-compat -Wcomma-subscript -Wvolatile -Wno-error=deprecated -Wduplicated-cond -Wimplicit-fallthrough -Wlogical-op -Wno-error=maybe-uninitialized -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-multistatement-macros -Wno-error=class-memaccess -Wformat -Wformat-overflow=2 -Wno-psabi -fno-strict-aliasing -ffp-contract=off  -MD -MP -MF .deps/morkStream.o.pp  -fdiagnostics-color  /NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/mailnews/db/mork/morkStream.cpp
+ /usr/bin/ccache /usr/bin/g++-12 --sysroot /home/ishikawa/.mozbuild/sysroot-x86_64-linux-gnu -std=gnu++17 -isystem /home/ishikawa/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/c++/7.5.0 -isystem /home/ishikawa/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/x86_64-linux-gnu/c++/7.5.0 -isystem /home/ishikawa/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/x86_64-linux-gnu -isystem /home/ishikawa/.mozbuild/sysroot-x86_64-linux-gnu/usr/include -o morkStream.o -c -I/NEW-SSD/moz-obj-dir/objdir-tb3/dist/stl_wrappers -I/NEW-SSD/moz-obj-dir/objdir-tb3/dist/system_wrappers -include /NEW-SSD/NREF-COMM-CENTRAL/mozilla/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -DDEBUG=1 -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DSTATIC_EXPORTABLE_JS_API -I/NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/mailnews/db/mork -I/NEW-SSD/moz-obj-dir/objdir-tb3/comm/mailnews/db/mork -I/NEW-SSD/moz-obj-dir/objdir-tb3/dist/include -I/NEW-SSD/moz-obj-dir/objdir-tb3/dist/include/nspr -I/NEW-SSD/moz-obj-dir/objdir-tb3/dist/include/nss -DMOZILLA_CLIENT -include /NEW-SSD/moz-obj-dir/objdir-tb3/mozilla-config.h -fno-sized-deallocation -fno-aligned-new -ldl -fno-builtin-strlen -Dfdatasync=fdatasync -DDEBUG_4GB_CHECK -DUSEHELGRIND=1 -DUSEVALGRIND=1 -DDEBUG -g -Werror=sign-compare -Werror=unused-result -Werror=unused-variable -Werror=format -fuse-ld=gold -fno-exceptions -fPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -g -g -Og -fvar-tracking -gdwarf-4 -fvar-tracking-assignments -freorder-blocks -fno-omit-frame-pointer -funwind-tables -Wall -Wempty-body -Wignored-qualifiers -Wpointer-arith -Wsign-compare -Wtype-limits -Wunreachable-code -Wno-invalid-offsetof -Wc++2a-compat -Wcomma-subscript -Wvolatile -Wno-error=deprecated -Wduplicated-cond -Wimplicit-fallthrough -Wlogical-op -Wno-error=maybe-uninitialized -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-multistatement-macros -Wno-error=class-memaccess -Wformat -Wformat-overflow=2 -Wno-psabi -fno-strict-aliasing -ffp-contract=off -MD -MP -MF .deps/morkStream.o.pp -fdiagnostics-color /NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/mailnews/db/mork/morkStream.cpp
In file included from /NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/mailnews/db/mork/morkPool.h:14,
                 from /NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/mailnews/db/mork/morkEnv.h:18,
                 from /NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/mailnews/db/mork/morkStream.cpp:23:
/NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/mailnews/db/mork/morkDeque.h: In static member function ‘static void morkNext::operator delete(void*)’:
/NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/mailnews/db/mork/morkDeque.h:65:31: error: ‘this’ pointer is null [-Werror=nonnull]
   65 |     ((morkNext*)0)->ZapOldNext((morkEnv*)0, (nsIMdbHeap*)0);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/NEW-SSD/NREF-COMM-CENTRAL/mozilla/comm/mailnews/db/mork/morkDeque.h:55:8: note: in a call to non-static member function ‘void morkNext::ZapOldNext(morkEnv*, nsIMdbHeap*)’
   55 |   void ZapOldNext(morkEnv* ev, nsIMdbHeap* ioHeap);
      |        ^~~~~~~~~~
cc1plus: some warnings being treated as errors
ishikawa@ip030:/NREF-COMM-CENTRAL/mozilla/comm$ 

The problem is triggered by the following code:
https://searchfox.org/comm-central/source/mailnews/db/mork/morkDeque.h#65


  void operator delete(void* ioAddress)  // DO NOT CALL THIS, hope to crash:
  {
    ((morkNext*)0)->ZapOldNext((morkEnv*)0, (nsIMdbHeap*)0);
  }  // boom

I think there is a problem in the code.
We are trying to use 0 as a pointer to begin with.
I suspect GCC-12 is inferring that we will crash due to null pointer reference by evaluating the constant pointer (= 0, i.e., nullptr on my x86_64 linux) ?

I think if we want to crash, we better call some kind of assert such as

MORK_ASSERT(0);  //  not sure if this really crashes at runtime
Assignee: nobody → ishikawa
Status: NEW → ASSIGNED

I think I screwed up the interaction between hg basic command including evolve extension and moz-phab and now I see two patches show up in the attachment. Hmm.
I simply tried to update it to use MOZ_ASSERT_UNREACHABLE.
But in between I wanted to post some other patches as well and that is where I think I got confused and
made a mistake.
(It would be great to have a documentation on how to update the tree M-C and C-C while you are still submitting patches using moz-phab. I am not entirely sure what to do before "hg pull -u".

MQ scenario to update the local tree and reapply the MQ patches.
Using MQ extension, I simply qpop all the pending MQ patches.
Then I executed |hg pull -u|,
Then I and then run "hg qpush -a" and resolve all the conflicts and merge failure.
(I created a special GNU Emacs macros to pinpoint where the context differs to cause the conflict to make the merge conflict easier to resolve.)

I wonder what exactly should I do to achieve what I do using MQ using EVOLVE?
And I wonder what should I not do to update the local tree while I have a multiple different / indepdent patches using EVOLVE scheme.
I am learning the ropes, but very slowly.

Attachment #9389319 - Attachment description: Bug 1817858 Use MORK_ASSERT(0) instead of 0-valued pointer to cause crash at runtime, r=mkmelin? → Bug 1817858 Use MOZ_ASSERT_UNREACHABLE("...") instead of 0-valued pointer to cause crash at runtime, r=mkmelin?

What I normally do to:

hg pull -u && hg up "public()"
hg rebase -s "draft()" -d "public()"
hg wip

For the extra revision you don't need, on the page use "Add action:" abandon revision.

Attachment #9389471 - Attachment description: Bug 1817858 Use MOZ_ASSERT_UNREACHABLE(...) instead of 0-valued pointer to cause crash at runtime, r=mkmelin? → Bug 1817858 Use MOZ_ASSERT_UNREACHABLE(...) instead of 0-valued pointer to cause crash at runtime, r=mkmelin

(In reply to Magnus Melin [:mkmelin] from comment #4)

What I normally do to:

hg pull -u && hg up "public()"
hg rebase -s "draft()" -d "public()"
hg wip

For the extra revision you don't need, on the page use "Add action:" abandon revision.

Thank you for the pointer!
This certainly helps to get the uninitiated going.

Type: enhancement → defect
Target Milestone: --- → 125 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/4b5db584a2be
Use MOZ_ASSERT_UNREACHABLE(...) instead of 0-valued pointer to cause crash at runtime, r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Attachment #9389319 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: