public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mark at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug analyzer/95188] analyzer-unsafe-call-within-signal-handler shows wrong statement for signal registration event
Date: Tue, 29 Sep 2020 14:09:43 +0000	[thread overview]
Message-ID: <bug-95188-4-kr2QOfYmeL@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95188-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95188

--- Comment #4 from Mark Wielaard <mark at gcc dot gnu.org> ---
Note that I can replicate it with the instructions in the description and gcc
git: gcc (GCC) 11.0.0 20200916 (experimental)

$ /opt/local/install/gcc/bin/gcc -g -O2 -fanalyzer -c bzip2.c 2>&1 | head -25
bzip2.c: In function ‘showFileNames.part.0’:
bzip2.c:677:4: warning: call to ‘fprintf’ from within signal handler [CWE-479]
[-Wanalyzer-unsafe-call-within-signal-handler]
  677 |    fprintf (
      |    ^~~~~~~~~
  678 |       stderr,
      |       ~~~~~~~
  679 |       "\tInput file = %s, output file = %s\n",
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  680 |       inName, outName
      |       ~~~~~~~~~~~~~~~
  681 |    );
      |    ~
  ‘main’: events 1-2
    |
    | 1776 | IntNative main ( IntNative argc, Char *argv[] )
    |      |           ^~~~
    |      |           |
    |      |           (1) entry to ‘main’
    | 1777 | {
    | 1778 |    Int32  i, j;
    |      |    ~~~~~   
    |      |    |
    |      |    (2) registering ‘mySIGSEGVorSIGBUScatcher’ as signal handler
    |
  event 3


It doesn't point at smallMode anymore, but the Int32 type isn't the right place
either.

For reference this is the main method starting at line 1776:

IntNative main ( IntNative argc, Char *argv[] )
{
   Int32  i, j;
   Char   *tmp;
   Cell   *argList;
   Cell   *aa;
   Bool   decode;

   /*-- Be really really really paranoid :-) --*/
   if (sizeof(Int32) != 4 || sizeof(UInt32) != 4  ||
       sizeof(Int16) != 2 || sizeof(UInt16) != 2  ||
       sizeof(Char)  != 1 || sizeof(UChar)  != 1)
      configError();

   /*-- Initialise --*/
   outputHandleJustInCase  = NULL;
   smallMode               = False;
   keepInputFiles          = False;
   forceOverwrite          = False;
   noisy                   = True;
   verbosity               = 0;
   blockSize100k           = 9;
   testFailsExist          = False;
   unzFailsExist           = False;
   numFileNames            = 0;
   numFilesProcessed       = 0;
   workFactor              = 30;
   deleteOutputOnInterrupt = False;
   exitValue               = 0;
   i = j = 0; /* avoid bogus warning from egcs-1.1.X */

   /*-- Set up signal handlers for mem access errors --*/
   signal (SIGSEGV, mySIGSEGVorSIGBUScatcher);

  parent reply	other threads:[~2020-09-29 14:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-18 13:28 [Bug analyzer/95188] New: " mark at gcc dot gnu.org
2020-09-16 23:02 ` [Bug analyzer/95188] " cvs-commit at gcc dot gnu.org
2020-09-16 23:27 ` dmalcolm at gcc dot gnu.org
2020-09-16 23:28 ` dmalcolm at gcc dot gnu.org
2020-09-29 14:09 ` mark at gcc dot gnu.org [this message]
2020-09-29 17:31 ` dmalcolm at gcc dot gnu.org
2020-09-29 18:13 ` mark at gcc dot gnu.org
2020-09-29 19:16 ` dmalcolm at gcc dot gnu.org
2020-09-29 22:33 ` cvs-commit at gcc dot gnu.org
2020-09-29 22:42 ` dmalcolm at gcc dot gnu.org
2020-09-30 22:00 ` mark at gcc dot gnu.org
2020-10-07 14:28 ` dmalcolm at gcc dot gnu.org
2020-10-07 20:05 ` mark at gcc dot gnu.org
2021-03-12 22:35 ` dmalcolm at gcc dot gnu.org
2022-03-25 20:28 ` [Bug analyzer/95188] State explosion on bzip2-1.0.8/bzip2.c hides -Wanalyzer-unsafe-call-within-signal-handler dmalcolm at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-95188-4-kr2QOfYmeL@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).