From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4DC1D397305F; Tue, 29 Sep 2020 14:09:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4DC1D397305F From: "mark at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: mark at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dmalcolm at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Sep 2020 14:09:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95188 --- Comment #4 from Mark Wielaard --- Note that I can replicate it with the instructions in the description and g= cc 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 =E2=80=98showFileNames.part.0=E2=80=99: bzip2.c:677:4: warning: call to =E2=80=98fprintf=E2=80=99 from within signa= l handler [CWE-479] [-Wanalyzer-unsafe-call-within-signal-handler] 677 | fprintf ( | ^~~~~~~~~ 678 | stderr, | ~~~~~~~ 679 | "\tInput file =3D %s, output file =3D %s\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 680 | inName, outName | ~~~~~~~~~~~~~~~ 681 | ); | ~ =E2=80=98main=E2=80=99: events 1-2 | | 1776 | IntNative main ( IntNative argc, Char *argv[] ) | | ^~~~ | | | | | (1) entry to =E2=80=98main=E2=80=99 | 1777 | { | 1778 | Int32 i, j; | | ~~~~~=20=20=20 | | | | | (2) registering =E2=80=98mySIGSEGVorSIGBUScatcher=E2=80=99 = as signal handler | event 3 It doesn't point at smallMode anymore, but the Int32 type isn't the right p= lace 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) !=3D 4 || sizeof(UInt32) !=3D 4 || sizeof(Int16) !=3D 2 || sizeof(UInt16) !=3D 2 || sizeof(Char) !=3D 1 || sizeof(UChar) !=3D 1) configError(); /*-- Initialise --*/ outputHandleJustInCase =3D NULL; smallMode =3D False; keepInputFiles =3D False; forceOverwrite =3D False; noisy =3D True; verbosity =3D 0; blockSize100k =3D 9; testFailsExist =3D False; unzFailsExist =3D False; numFileNames =3D 0; numFilesProcessed =3D 0; workFactor =3D 30; deleteOutputOnInterrupt =3D False; exitValue =3D 0; i =3D j =3D 0; /* avoid bogus warning from egcs-1.1.X */ /*-- Set up signal handlers for mem access errors --*/ signal (SIGSEGV, mySIGSEGVorSIGBUScatcher);=