On 04/04/2019 13:08, Phil Stracchino wrote:
I realized today that I hadn't updated my NAS (which runs a client and
an SD on Solaris 11.3 on amd64 hardware) from 9.4.1 to 9.4.2.  So I did
that tonight.'

Hi Phil,

I thought I'd posted my fixes...

There's a lot of anachronism warnings all exactly like this one:

"../config.h", line 1266: Warning (Anachronism): Attempt to redefine
__restrict__ without using #undef.

Wrapping line 1266 of config.h in an '#ifndef __restrict__ ... #endif'
handily gets rid of all of those.

This is a hangover from long, long ago:
$ diff -c original-bacula-9.4.2/autoconf/config.h.in bacula-9.4.2/autoconf/config.h.in
*** original-bacula-9.4.2/autoconf/config.h.in  Mon Mar  4 18:06:07 2019
--- bacula-9.4.2/autoconf/config.h.in   Mon Mar  4 18:11:18 2019
***************
*** 1255,1266 ****
     nothing if this is not supported.  Do not define if restrict is
     supported directly.  */
  #undef restrict
! /* Work around a bug in Sun C++: it does not support _Restrict or
__restrict__, even though the corresponding Sun C compiler ends up with
     "#define restrict _Restrict" or "#define restrict __restrict__" in the
     previous line.  Perhaps some future version of Sun C++ will work with
     restrict; if so, hopefully it defines __RESTRICT like Sun C does.  */
! #if defined __SUNPRO_CC && !defined __RESTRICT
  # define _Restrict
  # define __restrict__
  #endif
--- 1255,1266 ----
     nothing if this is not supported.  Do not define if restrict is
     supported directly.  */
  #undef restrict
! /* Work around a bug in old Sun C++: it does not support _Restrict or
__restrict__, even though the corresponding Sun C compiler ends up with
     "#define restrict _Restrict" or "#define restrict __restrict__" in the
     previous line.  Perhaps some future version of Sun C++ will work with
     restrict; if so, hopefully it defines __RESTRICT like Sun C does.  */
! #if defined __SUNPRO_CC && __SUNPRO_CC < 0x5150
  # define _Restrict
  # define __restrict__
  #endif

This behaviour probably changed in Sun C++ several versions ago, but the noise generated prior to the recent clean-up masked it.

Then there's a lot of "Likely null pointer dereference" warnings, all
originating from baconfig.h line 64 or 71, which appears to be the
definitions of ASSERT1 and ASSERT2.  I'm presuming these are deliberate
null dereferences to force a SIGSEGV on a failed ASSERT?

Yes, this lot are the mistaken use of *0 = 0 to cause an abort:
"../baconfig.h", line 64: Warning: Likely null pointer dereference (*(((char *)0)[0])): bRC_BXATTR BXATTR::serialize_xattr_stream

This looks like old C code used to cause a segmentation violation when something has gone wrong.
I wonder why "abort()" is not used?

What happens if you replace the assignments like "tjcr[0] = 0;" with "abort();"????
The code compiles, but does it still do what is expected??

There are three files affected:
        src/baconfig.h
        src/lib/lockmgr.c
        src/lib/message.c

$ diff -c -r original-bacula-9.4.2/src/baconfig.h bacula-9.4.2/src/baconfig.h
*** original-bacula-9.4.2/src/baconfig.h        Tue Feb  5 03:47:31 2019
--- bacula-9.4.2/src/baconfig.h Mon Mar  4 17:15:58 2019
***************
*** 61,67 ****
     char *tjcr = NULL; \
     Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
     Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
!    tjcr[0] = 0; }

  #define ASSERT2(x,y) if (!(x)) { \
     set_assert_msg(__FILE__, __LINE__, y); \
--- 61,67 ----
     char *tjcr = NULL; \
     Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
     Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
!    abort(); }

  #define ASSERT2(x,y) if (!(x)) { \
     set_assert_msg(__FILE__, __LINE__, y); \
***************
*** 68,74 ****
     Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
     Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
     char *tjcr = NULL; \
!    tjcr[0] = 0; }
  #else
  #define ASSERT(x)
  #define ASSERT2(x, y)
--- 68,74 ----
     Emsg1(M_ERROR, 0, _("Failed ASSERT: %s\n"), #x); \
     Pmsg1(000, _("Failed ASSERT: %s\n"), #x); \
     char *tjcr = NULL; \
!    abort(); }
  #else
  #define ASSERT(x)
  #define ASSERT2(x, y)

$ diff -c -r original-bacula-9.4.2/src/lib/lockmgr.c bacula-9.4.2/src/lib/lockmgr.c
*** original-bacula-9.4.2/src/lib/lockmgr.c     Tue Feb  5 03:47:31 2019
--- bacula-9.4.2/src/lib/lockmgr.c      Mon Mar  4 17:19:06 2019
***************
*** 53,70 ****
  #define ASSERT(x) if (!(x)) { \
     char *jcr = NULL; \
Pmsg3(000, _("ASSERT failed at %s:%i: %s\n"), __FILE__, __LINE__, #x); \
!    jcr[0] = 0; }

  #define ASSERT_p(x,f,l) if (!(x)) {              \
     char *jcr = NULL; \
     Pmsg3(000, _("ASSERT failed at %s:%i: %s \n"), f, l, #x); \
!    jcr[0] = 0; }

  #define ASSERT2_p(x,m,f,l) if (!(x)) {          \
     char *jcr = NULL; \
     set_assert_msg(f, l, m); \
Pmsg4(000, _("ASSERT failed at %s:%i: %s (%s)\n"), f, l, #x, m); \
!    jcr[0] = 0; }

/* for lockmgr unit tests we have to clean up developer flags and asserts which breaks our tests */
  #ifdef TEST_PROGRAM
--- 53,70 ----
  #define ASSERT(x) if (!(x)) { \
     char *jcr = NULL; \
Pmsg3(000, _("ASSERT failed at %s:%i: %s\n"), __FILE__, __LINE__, #x); \
!    abort(); }

  #define ASSERT_p(x,f,l) if (!(x)) {              \
     char *jcr = NULL; \
     Pmsg3(000, _("ASSERT failed at %s:%i: %s \n"), f, l, #x); \
!    abort(); }

  #define ASSERT2_p(x,m,f,l) if (!(x)) {          \
     char *jcr = NULL; \
     set_assert_msg(f, l, m); \
Pmsg4(000, _("ASSERT failed at %s:%i: %s (%s)\n"), f, l, #x, m); \
!    abort(); }

/* for lockmgr unit tests we have to clean up developer flags and asserts which breaks our tests */
  #ifdef TEST_PROGRAM

$ diff -c -r original-bacula-9.4.2/src/lib/message.c bacula-9.4.2/src/lib/message.c
*** original-bacula-9.4.2/src/lib/message.c     Tue Feb  5 03:47:31 2019
--- bacula-9.4.2/src/lib/message.c      Mon Mar  4 17:17:12 2019
***************
*** 1413,1419 ****

      if (type == M_ABORT) {
         char *p = 0;
! p[0] = 0; /* generate segmentation violation */
      }
      if (type == M_ERROR_TERM) {
         exit(1);
--- 1413,1419 ----

      if (type == M_ABORT) {
         char *p = 0;
!        abort();                      /* generate segmentation violation */
      }
      if (type == M_ERROR_TERM) {
         exit(1);
***************
*** 1551,1557 ****
         char *p = 0;
         printf("Bacula forced SEG FAULT to obtain traceback.\n");
syslog(LOG_DAEMON|LOG_ERR, "Bacula forced SEG FAULT to obtain traceback.\n"); ! p[0] = 0; /* generate segmentation violation */
      }
      if (type == M_ERROR_TERM) {
         exit(1);
--- 1551,1557 ----
         char *p = 0;
         printf("Bacula forced SEG FAULT to obtain traceback.\n");
syslog(LOG_DAEMON|LOG_ERR, "Bacula forced SEG FAULT to obtain traceback.\n");
!        abort();                      /* generate segmentation violation */
      }
      if (type == M_ERROR_TERM) {
         exit(1);

And finally a lot of "XXXX hides the virtual function ..." and "XXXX
hides BDB::XXXX" warnings.  I don't know enough C++ to know what to do
about those, but they don't seem to be critical.

The bane of C++ coding, what happens when you have declarations mixed in with definitions?

"../lib/cmd_parser.h", line 92: Warning: args hides cmd_parser::args.
"../stored/aligned_dev.h", line 139: Warning: aligned_dev::get_full_addr hides the virtual function DEVICE::get_full_addr(unsigned, unsigned).

The G++ developers appear to consider this benign, which it is, except, of course, when it isn't.

The build succeeded with all the above warnings and appears to be
working fine.


I applied my __restrict fix, and changed things to use abort() (which is guaranteed to be portable), and ignored the "hides" warnings, it's been running on the 11.3 director and clients since March 22nd, seems fine, but only time will tell :-)

Maybe I'll start porting it to the AIX/HP/Linux boxes someday... (I don't think it will build on the old AIX and HP systems, nor some of the ancient Linux boxes.)

        Cheers,
                Gary    B-)


_______________________________________________
Bacula-devel mailing list
Bacula-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-devel

Reply via email to