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

h2xs: avoid infinite loop for enums #15694

Closed
p5pRT opened this issue Nov 2, 2016 · 5 comments
Closed

h2xs: avoid infinite loop for enums #15694

p5pRT opened this issue Nov 2, 2016 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 2, 2016

Migrated from rt.perl.org#130001 (status was 'resolved')

Searchable as RT130001$

@p5pRT
Copy link
Author

p5pRT commented Nov 2, 2016

From @hvds

Created by @hvds

A header file that has an enum and a type of the same name can cause
h2xs to loop trying to resolve expandable types when trying to generate
the typemap. Eg with test.h like​:

  typedef enum colour_t {
  RED = 1,
  GREEN,
  BLUE
  } colour_t;

  extern void set_colour(colour_t colour);

.. the command 'h2xs -x test.h' will fail, as I found while looking at
sensors/sensors.h from the lm-sensors package.

The change below fixes that, in the same way it already avoids the same
problem for structs. I'll push it once I have the perlbug ref.

--- a/utils/h2xs.PL
+++ b/utils/h2xs.PL
@​@​ -1034,7 +1034,7 @​@​ if( ! $opt_X ){ # use XS, unless it was disabled
  }
  }
  { local $" = '|';
- $typedef_rex = qr(\b(?<!struct )(?​:@​good_td)\b) if @​good_td;
+ $typedef_rex = qr(\b(?<!struct )(?<!enum )(?​:@​good_td)\b) if @​good_td;
  }
  %known_fnames = map @​$_[1,3], @​$fdecls_parsed; # [1,3] is NAME, FULLTEXT
  if ($fmask) {

Perl Info

Flags:
    category=utilities
    severity=low

Site configuration information for perl 5.25.7:

Configured by hv at Wed Nov  2 14:23:18 GMT 2016.

Summary of my perl5 (revision 5 version 25 subversion 7) configuration:
  Commit id: 6d31468305788870c92226c07d8edd65deb96ea5
  Platform:
    osname=linux
    osvers=3.13.0-37-generic
    archname=x86_64-linux
    uname='linux shad2 3.13.0-37-generic #64-ubuntu smp mon sep 22 21:28:38 utc 2014 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des -Dcc=gcc -Dprefix=/opt/blead-d0 -Doptimize=-g -O0 -DDEBUGGING -Dusedevel -Uversiononly'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    bincompat5005=undef
  Compiler:
    cc='gcc'
    ccflags ='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-g -O0'
    cppflags='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion=''
    gccversion='4.8.4'
    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='gcc'
    ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /lib64 /usr/lib64
    libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.19.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.19'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -g -O0 -L/usr/local/lib -fstack-protector'



@INC for perl 5.25.7:
    /opt/blead-d0/lib/perl5/site_perl/5.25.7/x86_64-linux
    /opt/blead-d0/lib/perl5/site_perl/5.25.7
    /opt/blead-d0/lib/perl5/5.25.7/x86_64-linux
    /opt/blead-d0/lib/perl5/5.25.7


Environment for perl 5.25.7:
    HOME=/home/hv
    LANG=C
    LANGUAGE=en_GB:en
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/hv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Nov 2, 2016

From @hvds

Now pushed​:

commit 9ce5bf4
Author​: Hugo van der Sanden <hv@​crypt.org>
Date​: Fri Oct 28 13​:27​:23 2016 +0100

  [perl #130001] h2xs​: avoid infinite loop for enums
 
  'typedef enum x { ... } x' causes h2xs to enter a substitution loop while
  trying to write the typemap file.

Hugo

@p5pRT
Copy link
Author

p5pRT commented Nov 2, 2016

@hvds - Status changed from 'new' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release today of Perl 5.26.0, this and 210 other issues have been
resolved.

Perl 5.26.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.26.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

@khwilliamson - Status changed from 'pending release' to 'resolved'

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