Thanks to visit codestin.com
Credit goes to github.com

Skip to content

probably incorrect flags value in assertion #21005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tonycoz opened this issue Apr 4, 2023 · 0 comments
Open

probably incorrect flags value in assertion #21005

tonycoz opened this issue Apr 4, 2023 · 0 comments

Comments

@tonycoz
Copy link
Contributor

tonycoz commented Apr 4, 2023

Module:

Description

Coverity scan complains about this like in regexec.c (and re_exec.c):

assert(!(FLAGS(scan) & ~RXf_PMf_COMPILETIME));

With the message:

CID 451332 (#1-3 of 3): Operands don't affect result (CONSTANT_EXPRESSION_RESULT)result_independent_of_operands: scan->head.data.u_8.flags & 4294965248U /* ~(((((((((1U << 0 + 0) | (1U << 0 + 1)) | (1U << 0 + 2)) | (1U << 0 + 3)) | (1U << 0 + 4)) | (1U << 0 + 6)) | (1U << 0 + 5)) | (7U << 0 + 7)) | (1U << 0 + 10)) */ is always 0 regardless of the values of its operands. This occurs as the logical operand of !.

which happens since the flags member is only and 8 bit value and this code masks it with 4294965248U, which is 0xfffff800.

From looking at the code that uses the flags that make up RXf_PMf_COMPILETIME I'm pretty sure this shouldn't be testing against the flags of the current op, but either against RExC_flags or ARG2i(scan).

@demerphq recently changed this from scan->flags to FLAGS(scan) which I don't think is the cause of Coverity's complaint but the original assertion was added in ec841a2 by @iabyn

Steps to Reproduce

N/A
Expected behavior

N/A
Perl configuration

Summary of my perl5 (revision 5 version 37 subversion 11) configuration:
  Commit id: 59402972ce26ccbcf5c463e9bf544fd57c8dd513
  Platform:
    osname=linux
    osvers=5.10.0-21-amd64
    archname=x86_64-linux-thread-multi
    uname='linux venus 5.10.0-21-amd64 #1 smp debian 5.10.162-1 (2023-01-21) x86_64 gnulinux '
    config_args='-des -Dusedevel -DDEBUGGING -Doptimize=-O0 -ggdb3 -Dusethreads'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-O0 -ggdb3'
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='10.2.1 20210110'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/x86_64-linux-gnu /usr/lib /usr/lib64
    libs=-lpthread -lgdbm -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.31.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.31'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O0 -ggdb3 -L/usr/local/lib -fstack-protector-strong'

Characteristics of this binary (from libperl): 
  Compile-time options:
    DEBUGGING
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_SIPHASH13
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_TRACK_MEMPOOL
    PERL_USE_DEVEL
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
    USE_THREAD_SAFE_LOCALE
  Built under linux
  Compiled at Apr  4 2023 10:43:51
  %ENV:
    PERLBREW_BASHRC_VERSION="0.43"
    PERLBREW_HOME="/home/tony/.perlbrew"
    PERLBREW_MANPATH=""
    PERLBREW_PATH="/home/tony/perl5/perlbrew/bin"
    PERLBREW_ROOT="/home/tony/perl5/perlbrew"
    PERLBREW_VERSION="0.67"
  @INC:
    lib
    /usr/local/lib/perl5/site_perl/5.37.11/x86_64-linux-thread-multi
    /usr/local/lib/perl5/site_perl/5.37.11
    /usr/local/lib/perl5/5.37.11/x86_64-linux-thread-multi
    /usr/local/lib/perl5/5.37.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant