Skip to content
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

BBC: Blead Breaks EV #22353

Open
cjg-cguevara opened this issue Jun 29, 2024 · 7 comments
Open

BBC: Blead Breaks EV #22353

cjg-cguevara opened this issue Jun 29, 2024 · 7 comments
Labels
BBC Blead Breaks CPAN - changes in blead broke a cpan module(s)

Comments

@cjg-cguevara
Copy link

This is a bug report for perl from "Carlos Guevara" [email protected],
generated with the help of perlbug 1.43 running under perl 5.41.1.


BBC: Blead Breaks EV

Please see http://fast-matrix.cpantesters.org/?dist=EV%204.34


Flags

  • category=core
  • severity=low

Perl configuration

Site configuration information for perl 5.41.1:

Configured by cpan at Fri Jun 28 23:41:57 EDT 2024.

Summary of my perl5 (revision 5 version 41 subversion 1) configuration:
  Commit id: 99e7291a160c07384076cfdcf5b3126143155452
  Platform:
    osname=linux
    osvers=5.14.0-427.22.1.el9_4.x86_64
    archname=x86_64-linux-thread-multi
    uname='linux cjg-rhel9 5.14.0-427.22.1.el9_4.x86_64 #1 smp preempt_dynamic mon jun 10 09:23:36 edt 2024 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des -Dprefix=/home/cpan/bin/perl -Dscriptdir=/home/cpan/bin/perl/bin -Dusedevel -Duse64bitall -Duseithreads'
    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 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-O2'
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='11.4.1 20231218 (Red Hat 11.4.1-3)'
    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 /usr/lib64 /usr/local/lib64
    libs=-lpthread -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=/lib/../lib64/libc.so.6
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.34'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'


---
@INC for perl 5.41.1:
    /home/cpan/bin/perl/lib/site_perl/5.41.1/x86_64-linux-thread-multi
    /home/cpan/bin/perl/lib/site_perl/5.41.1
    /home/cpan/bin/perl/lib/5.41.1/x86_64-linux-thread-multi
    /home/cpan/bin/perl/lib/5.41.1

---
Environment for perl 5.41.1:
    HOME=/home/cpan
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_ALL=C
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/cpan/bin/perl/bin:/home/cpan/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash
@mauke
Copy link
Contributor

mauke commented Jun 29, 2024

This is a typemap error. I haven't bisected it, but I strongly suspect commit 2f4409b:

Use alert control character as quoting character in INPUT templates

This way, one no longer needs to escape double quotes inside an input template.

The typemap in EV contains this:

INPUT

T_WATCHER
	if (!(SvROK ($arg) && SvOBJECT (SvRV ($arg))
              && (SvSTASH (SvRV ($arg)) == stash_" . ($type =~ /ev_(\S+)/, "$1") . "
                  || sv_derived_from ($arg, \"EV::" . ($type =~ /ev_(\S+)/, ucfirst "$1") . "\"))))
          croak (\"object is not of type EV::" . ($type =~ /ev_(\S+)/, ucfirst "$1") . "\");
	$var = ($type)SvPVX (SvRV ($arg));

I.e. it deliberately uses unescaped " to break out of the quoting and inject Perl code.

Fixing it should be easy because the OUTPUT section also does it, but using ${...} instead:

T_WATCHER
	$arg = e_bless ((struct ev_watcher *)$var, stash_${ ($type =~ /ev_(\S+)/, \"$1") });

If I understand the situation correctly, using the ${...} trick in the INPUT section should work and be compatible with previous ExtUtils::ParseXS versions. @Leont ?

@Leont
Copy link
Contributor

Leont commented Jun 29, 2024

This is a typemap error. I haven't bisected it, but I strongly suspect commit 2f4409b:

Yeah definitely.

If I understand the situation correctly, using the ${...} trick in the INPUT section should work and be compatible with previous ExtUtils::ParseXS versions. @Leont ?

And yes ${ ... } is the way that works consistently everywhere.

@jkeenan jkeenan added BBC Blead Breaks CPAN - changes in blead broke a cpan module(s) and removed Needs Triage labels Jun 29, 2024
@Leont
Copy link
Contributor

Leont commented Jun 29, 2024

This seems to fix it

diff --git typemap typemap
index f30badc..ea5c33b 100644
--- typemap
+++ typemap
@@ -37,9 +37,9 @@ T_LOOP
 
 T_WATCHER
    if (!(SvROK ($arg) && SvOBJECT (SvRV ($arg))
-              && (SvSTASH (SvRV ($arg)) == stash_" . ($type =~ /ev_(\S+)/, "$1") . "
-                  || sv_derived_from ($arg, \"EV::" . ($type =~ /ev_(\S+)/, ucfirst "$1") . "\"))))
-          croak (\"object is not of type EV::" . ($type =~ /ev_(\S+)/, ucfirst "$1") . "\");
+              && (SvSTASH (SvRV ($arg)) == stash_${ ($type =~ /ev_(\S+)/, \"$1") }
+                  || sv_derived_from ($arg, \"EV::${ ($type =~ /ev_(\S+)/, \ucfirst "$1") }\"))))
+          croak (\"object is not of type EV::${ ($type =~ /ev_(\S+)/, \ucfirst "$1") }\");
    $var = ($type)SvPVX (SvRV ($arg));
 
 OUTPUT

@jkeenan
Copy link
Contributor

jkeenan commented Jun 29, 2024

Bisecting with this invocation:

perl Porting/bisect.pl \
--start=56d5b6ef820802cd4c57fc2cfd8301a3f5d7af04 \
--end=99e7291a160c07384076cfdcf5b3126143155452 \
--module=EV

... pointed to commit 2f4409b

commit 2f4409bf707ec51ce63fd97c981a2c9e08b97241
Author: Leon Timmermans <[email protected]>
Date:   Fri Jun 14 01:08:03 2024 +0200
Commit:     Leon Timmermans <[email protected]>
CommitDate: Mon Jun 24 05:30:37 2024 +0100

    Use alert control character as quoting character in INPUT templates

    This way, one no longer needs to escape double quotes inside an input
    template.

    Parsexs has done this for OUTPUT templates since the very beginning, I
    can't find any reason for why we weren't also doing it for INPUT
    templates.

@Leont
Copy link
Contributor

Leont commented Jul 1, 2024

Based on some grepping there are two more modules that used this "feature", but both of them were already broken when ParseXS was made strict 12 years ago and never even had that fixed so they can be considered dead.

@jkeenan
Copy link
Contributor

jkeenan commented Jul 1, 2024 via email

@Leont
Copy link
Contributor

Leont commented Jul 1, 2024

Just for the record, those two other modules are ... ?

Gtk-perl and Etk-perl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BBC Blead Breaks CPAN - changes in blead broke a cpan module(s)
Projects
None yet
Development

No branches or pull requests

4 participants