sparse regex error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Luc,

Long time no hear! ;)

About 18 months ago, I updated my Linux installation and sparse started
to fail when run during my git build. The reason for the failure was,
ultimately, a change to the 'regex.h' header file as a result of the
update from one Ubuntu LTS base to the current Ubuntu LTS base.
In particular, an update to the libc6-devel package from 2.31 to 2.35
which (in part) looked like this:

.

524a525,548
> #ifndef _REGEX_NELTS
> # if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \
>       && !defined __STDC_NO_VLA__)
> #  define _REGEX_NELTS(n) n
> # else
> #  define _REGEX_NELTS(n)
> # endif
> #endif
> 

.

645c681,682
<                   regmatch_t __pmatch[_Restrict_arr_],
---
>                   regmatch_t __pmatch[_Restrict_arr_
>                                       _REGEX_NELTS (__nmatch)],

.

The last hunk is the declaration of regexec(), thus:

extern int regexec (const regex_t *_Restrict_ __preg,
                    const char *_Restrict_ __String, size_t __nmatch,
                    regmatch_t __pmatch[_Restrict_arr_
                                        _REGEX_NELTS (__nmatch)],
                    int __eflags);

To fix my build, I added the following to my config.mak file on linux:

    SPARSE_FLAGS += -D__STDC_NO_VLA__

. and immediately started working on a fix to sparse! Oh wait ... :)

I did report the problem and the above workaround on the git ML [1], and
created a test in my sparse repo to demonstrate the problem, thus:

  $ git diff
  diff --git a/validation/restrict-array.c b/validation/restrict-array.c
  index 04bfdad9..86753b7d 100644
  --- a/validation/restrict-array.c
  +++ b/validation/restrict-array.c
  @@ -29,9 +29,19 @@ typedef unsigned long int size_t;
   
   extern int regexec (const regex_t *__restrict __preg,
                      const char *__restrict __string, size_t __nmatch,
  -                   regmatch_t __pmatch[__restrict_arr],
  +                   regmatch_t __pmatch[__restrict_arr __nmatch],
                      int __eflags);
   
  +static int call_regexec(const regex_t *r)
  +{
  +       char s[] = "something to search";
  +       regmatch_t pm[5];
  +
  +       if (regexec(r, s, 5, pm, 0))
  +               return 0;
  +       return 1;
  +}
  +
   /*
    * check-name: restrict array attribute
    */
  $ 

which, similarly to git, shows errors not on the declaration of the
regexec() function, but on each call site (about a dozen in git):

  $ ./sparse validation/restrict-array.c
  validation/restrict-array.c:32:56: error: undefined identifier '__nmatch'
  validation/restrict-array.c:32:56: error: bad constant expression type
  $ 

I have tried to find the time, in the last couple of days, to take a look
and find a fix for this, but I have had to admit defeat and just content
myself with noting the problem here. :(

Maybe I will find some time over the xmas break.

[1] https://lore.kernel.org/git/7498bff0-782f-8c81-5817-ed841f12dbba@xxxxxxxxxxxxxxxxxxxx/

ATB,
Ramsay Jones





[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux