Bug 97394 - Incorrect analyzer output for setjmp
Summary: Incorrect analyzer output for setjmp
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: analyzer (show other bugs)
Version: 10.2.0
: P3 normal
Target Milestone: ---
Assignee: David Malcolm
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-13 02:14 UTC by Michael Morrell
Modified: 2020-10-14 20:55 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Header file (316 bytes, text/x-csrc)
2020-10-13 02:14 UTC, Michael Morrell
Details
Source file (131 bytes, text/x-csrc)
2020-10-13 02:15 UTC, Michael Morrell
Details
Expected output (178 bytes, text/plain)
2020-10-13 02:15 UTC, Michael Morrell
Details
Incorrect output (178 bytes, text/plain)
2020-10-13 02:16 UTC, Michael Morrell
Details
[PATCH] analyzer: don't use <setjmp.h> in tests [PR97394] (1.06 KB, patch)
2020-10-13 20:38 UTC, David Malcolm
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Morrell 2020-10-13 02:14:42 UTC
Created attachment 49356 [details]
Header file

While testing gcc 10.2 with MUSL for libc, I noticed some of analyzer setjmp tests in the gcc validation suite were failing.

I managed to get a somewhat reduced testcase and determined that the problem was due to this #define in setjmp.h for MUSL:

#define setjmp setjmp

In glibc, the corresponding #define is:

#define setjmp(env) _setjmp(env)

and the testcases pass when that is used.
Comment 1 Michael Morrell 2020-10-13 02:15:22 UTC
Created attachment 49357 [details]
Source file
Comment 2 Michael Morrell 2020-10-13 02:15:46 UTC
Created attachment 49358 [details]
Expected output
Comment 3 Michael Morrell 2020-10-13 02:16:07 UTC
Created attachment 49359 [details]
Incorrect output
Comment 4 Michael Morrell 2020-10-13 02:17:01 UTC
To run this, just use "gcc -fanalyzer -S -o /dev/null setjmp.c"
Comment 5 David Malcolm 2020-10-13 20:38:31 UTC
Created attachment 49366 [details]
[PATCH] analyzer: don't use <setjmp.h> in tests [PR97394]

Thanks for filing this bug.  Does this patch fix the testsuite for you?
Comment 6 Michael Morrell 2020-10-14 00:46:34 UTC
Yes, thanks for the quick fix.
Comment 7 GCC Commits 2020-10-14 20:37:21 UTC
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:974e3975c5bd14ee8817f892532d1e55492227df

commit r11-3894-g974e3975c5bd14ee8817f892532d1e55492227df
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Tue Oct 13 15:56:45 2020 -0400

    analyzer: don't use <setjmp.h> in tests [PR97394]
    
    PR analyzer/97394 reports issues with analyzer setjmp results
    when testing against MUSL.  This patch fixes up gcc.dg/analyzer
    so that it doesn't use <setjmp.h>.
    
    gcc/testsuite/ChangeLog:
            PR analyzer/97394
            * gcc.dg/analyzer/setjmp-pr93378.c: Use test-setjmp.h rather than
            <setjmp.h>.
            * gcc.dg/analyzer/sigsetjmp-5.c: Likewise.
            * gcc.dg/analyzer/sigsetjmp-6.c: Likewise.
            * gcc.dg/analyzer/test-setjmp.h: Don't include <setjmp.h>.
            Provide decls of jmp_buf, sigjmp_buf, setjmp, sigsetjmp,
            longjmp, and siglongjmp.
Comment 8 David Malcolm 2020-10-14 20:55:22 UTC
(In reply to Michael Morrell from comment #6)
> Yes, thanks for the quick fix.

Thanks for confirming.