bugfindutils - Bugs: bug #57277, FAIL: test-canonicalize-lgpl with...

 
 

bug #57277: FAIL: test-canonicalize-lgpl with GCC 10

Submitter:  Martin Liška <marxin>
Submitted:  Wed 20 Nov 2019 02:55:21 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  berny
Originator Name:  Open/Closed:  Closed
Release:  4.7.0 Fixed Release:  4.8.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 06 Jan 2020 01:06:58 PM UTC, comment #6: 

Thanks, Bruno.

The attached picks up the gnulib patch by updating to latest.
Pushed at:
https://git.sv.gnu.org/cgit/findutils.git/commit/?id=28f11d689dc6




(file #48170)

Bernhard Voelker <berny>
Group administrator
Sun 05 Jan 2020 10:53:43 PM UTC, comment #5: 
Bruno Haible <haible>
Thu 21 Nov 2019 11:07:15 AM UTC, comment #4: 


> One can't decorate a function with nonnull attribute and then call the function with NULL. Doing that, an optimizing compiler can do aggressive optimizations.


_attribute_ __nonnull__ actually means two things:
1) The compiler may emit warnings when the function is invoked with null arguments.
2) Unless the option -fno-delete-null-pointer-checks is specified, the compiler may make optimizations, assuming that the function will not be invoked with null arguments.

Source: https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Common-Function-Attributes.html

> either ... or ...


Or you pass the option -fno-delete-null-pointer-checks when compiling the code. (I'm not asking you to use this option. Only clarifying that there is a third choice.)

Bruno Haible <haible>
Thu 21 Nov 2019 09:37:45 AM UTC, comment #3: 


comment #1:

> First of all, the fix for this should go into gnulib --> adding their ML.
>
> Then, this test actually wants to verify the behavior of that
> function when called with a NULL value (it should return NULL
> and set errno to EINVAL).
> Therefore, the test needs to suppress that specific sanitizer
> error.


No, it's not a sanitizer error, it's an error in gnulib code. One can't
decorate a function with nonnull attribute and then call the function
with NULL. Doing that, an optimizing compiler can do aggressive optimizations.
So either the function canonicalize_file_name should accept (and handle NULL),
then remove the nonnull attribute, or it can't and then one can't call
the function with NULL.
Thanks.

 I don't have a GCC 10, so does something like the

> following work?
>


> a/tests/test-canonicalize-lgpl.c b/tests/test-canonicalize-lgpl.c
> index 4ce06e46c..4e7d47c57 100644
> --- a/tests/test-canonicalize-lgpl.c
> +++ b/tests/test-canonicalize-lgpl.c
> @@ -39,6 +39,9 @@ SIGNATURE_CHECK (canonicalize_file_name, char *, (const char *));
>
>  #define BASE "t-can-lgpl.tmp"
>
> +/* Suppress -fsanitize=null error - seen on GCC 10 - for this test.  */
> +extern char *canonicalize_file_name (const char *) __attribute__((no_sanitize("null")));
> +
>  int
>  main (void)
>  {


Martin Liška <marxin>
Thu 21 Nov 2019 02:15:35 AM UTC, comment #2: 

Will this patch, that uses the same technique as canonicalize-lgpl.c, work? I can't test it, because I don't have a GCC 10 installed.


diff --git a/tests/test-canonicalize-lgpl.c b/tests/test-canonicalize-lgpl.c
index 4ce06e4..d9a9773 100644
--- a/tests/test-canonicalize-lgpl.c
+++ b/tests/test-canonicalize-lgpl.c
@@ -16,6 +16,10 @@

 /* Written by Bruno Haible <bruno@clisp.org>, 2007.  */

+/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise the
+   undefined-behaviour of GCC or clang may let the test with null_ptr crash.  */
+#define _GL_ARG_NONNULL(params)
+
 #include <config.h>

 #include <stdlib.h>


Bruno Haible <haible>
Wed 20 Nov 2019 11:49:54 PM UTC, comment #1: 

First of all, the fix for this should go into gnulib --> adding their ML.

Then, this test actually wants to verify the behavior of that
function when called with a NULL value (it should return NULL
and set errno to EINVAL).
Therefore, the test needs to suppress that specific sanitizer
error. I don't have a GCC 10, so does something like the
following work?


a/tests/test-canonicalize-lgpl.c b/tests/test-canonicalize-lgpl.c
index 4ce06e46c..4e7d47c57 100644
--- a/tests/test-canonicalize-lgpl.c
+++ b/tests/test-canonicalize-lgpl.c
@@ -39,6 +39,9 @@ SIGNATURE_CHECK (canonicalize_file_name, char *, (const char *));

 #define BASE "t-can-lgpl.tmp"

+/* Suppress -fsanitize=null error - seen on GCC 10 - for this test.  */
+extern char *canonicalize_file_name (const char *) __attribute__((no_sanitize("null")));
+
 int
 main (void)
 {


Bernhard Voelker <berny>
Group administrator
Wed 20 Nov 2019 02:55:21 PM UTC, original submission:  

Similarly to:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=38280

the test fails for the very same reason.

Martin Liška <marxin>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #48170:  0001-maint-update-gnulib-to-latest.patch added by berny (735B - text/x-patch - [PATCH] maint: update gnulib to latest)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by haible (Posted a comment)
  • -email is unavailable- added by berny (Posted a comment)
  • -email is unavailable- added by berny (FAIL: test-canonicalize-lgpl with GCC 10)
  • -email is unavailable- added by marxin (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-01-09 berny Open/ClosedOpen Closed
        ReleaseNone 4.7.0
        Fixed ReleaseNone 4.8.0
    2020-01-06 berny Attached File- Added 0001-maint-update-gnulib-to-latest.patch, #48170
        StatusNone Fixed
    2020-01-06 berny Assigned toNone berny
    2019-11-20 berny Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code