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

h2ph not correctly processing glibc sys/sysmacros.ph #7322

Closed
p5pRT opened this issue May 30, 2004 · 7 comments
Closed

h2ph not correctly processing glibc sys/sysmacros.ph #7322

p5pRT opened this issue May 30, 2004 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented May 30, 2004

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

Searchable as RT29969$

@p5pRT
Copy link
Author

p5pRT commented May 30, 2004

From @samv

Created by @samv

Hi,

h2ph sys/sysmacros.h incorrectly translates this​:

# define makedev(major, minor) { ((((unsigned int) (major)) << 8) \
  | ((unsigned int) (minor))), 0 }

to this​:

  eval "\n#line 10 sys/sysmacros.ph\n" . 'sub makedev {
  local($major, $minor) = @​_;
  eval q({ (( << 8) | ( ($minor))), 0});
  }' unless defined(&makedev);

This is a syntax error; it should read​:

  eval "\n#line 10 sys/sysmacros.ph\n" . 'sub makedev {
  local($major, $minor) = @​_;
  eval q({ (($major << 8) | ( ($minor))), 0});
  }' unless defined(&makedev);

Any ideas?

Perl Info

Flags:
    category=utilities
    severity=low

Site configuration information for perl v5.8.3:

Configured by Debian Project at Sun Feb 15 17:22:09 EST 2004.

Summary of my perl5 (revision 5.0 version 8 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.4.22-xfs+ti1211, archname=i386-linux-thread-multi
    uname='linux kosh 2.4.22-xfs+ti1211 #1 sat oct 25 10:11:37 est 2003 i686 gnulinux '
    config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i386-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.8.3 -Dsitearch=/usr/local/lib/perl/5.8.3 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Uusenm -Duseshrplib -Dlibperl=libperl.so.5.8.3 -Dd_dosuid -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O3',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='3.3.3 20040125 (prerelease) (Debian)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
    perllibs=-ldl -lm -lpthread -lc -lcrypt
    libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libperl.so.5.8.3
    gnulibc_version='2.3.2'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.3:
    /etc/perl
    /usr/local/lib/perl/5.8.3
    /usr/local/share/perl/5.8.3
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.8
    /usr/share/perl/5.8
    /usr/local/lib/site_perl
    /usr/local/lib/perl/5.8.1
    .


Environment for perl v5.8.3:
    HOME=/home/samv
    LANG=en_NZ
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/samv/bin:/usr/local/kde/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/mozilla:/usr/java/j2re1.4.2_04/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented May 30, 2004

From wolfgang.laun@chello.at

At 30 May 2004 02​:51​:10 -0000 Sam Vilain wrote​:

h2ph sys/sysmacros.h incorrectly translates this​:

# define makedev(major, minor) { ((((unsigned int) (major)) << 8) \
| ((unsigned int) (minor))), 0 }
[snip]
Any ideas?

Yes.

Inline Patch
--- h2ph.old	Sat Jan 17 09:38:29 2004
+++ h2ph	Sun May 30 16:57:41 2004
@@ -346,10 +346,16 @@
         };
 	# Eliminate typedefs
 	/\(([\w\s]+)[\*\s]*\)\s*[\w\(]/ && do {
+	    my $doit = 1;
 	    foreach (split /\s+/, $1) {  # Make sure all the words are types,
-		last unless ($isatype{$_} or $_ eq 'struct' or $_ eq 'union');
+	        unless($isatype{$_} or $_ eq 'struct' or $_ eq 'union'){
+		    $doit = 0;
+		    last;
+		}
+	    }
+	    if( $doit ){
+		s/\([\w\s]+[\*\s]*\)// && next;      # then eliminate them.
 	    }
-	    s/\([\w\s]+[\*\s]*\)// && next;      # then eliminate them.
 	};
 	# struct/union member, including arrays:
 	s/^([_A-Z]\w*(\[[^\]]+\])?((\.|->)[_A-Z]\w*(\[[^\]]+\])?)+)//i && do {

@p5pRT
Copy link
Author

p5pRT commented May 30, 2004

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented May 31, 2004

From @rgs

wolfgang.laun@​chello.at wrote​:

At 30 May 2004 02​:51​:10 -0000 Sam Vilain wrote​:

h2ph sys/sysmacros.h incorrectly translates this​:

# define makedev(major, minor) { ((((unsigned int) (major)) << 8) \
| ((unsigned int) (minor))), 0 }
[snip]
Any ideas?

Yes.

Thanks, applied as #22877 (to h2ph.PL).

--- h2ph.old Sat Jan 17 09​:38​:29 2004
+++ h2ph Sun May 30 16​:57​:41 2004

@p5pRT
Copy link
Author

p5pRT commented Jun 1, 2004

@rspier - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Jun 1, 2004
@p5pRT
Copy link
Author

p5pRT commented Jun 10, 2004

From @rgs

Sam Vilain (via RT) wrote​:

h2ph sys/sysmacros.h incorrectly translates this​:

# define makedev(major, minor) { ((((unsigned int) (major)) << 8) \
| ((unsigned int) (minor))), 0 }

to this​:

        eval "\\n\#line 10 sys/sysmacros\.ph\\n" \. 'sub makedev \{
            local\($major\, $minor\) = @&#8203;\_;
            eval q\(\{ \(\( \<\< 8\) | \( \($minor\)\)\)\, 0\}\);
        \}' unless defined\(&makedev\);

This is a syntax error; it should read​:

        eval "\\n\#line 10 sys/sysmacros\.ph\\n" \. 'sub makedev \{
            local\($major\, $minor\) = @&#8203;\_;
            eval q\(\{ \(\($major \<\< 8\) | \( \($minor\)\)\)\, 0\}\);
        \}' unless defined\(&makedev\);

Wait, the story is not over; in recent glibcs (glibc-devel-2.3.3-12mdk)
sysmacros.h contains evil inline functions​:

  __extension__ extern __inline unsigned int
  gnu_dev_major (unsigned long long int __dev) __THROW
  {
  return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
  }

and so on.

h2ph doesn't grok this. I think it should be patched...

@p5pRT
Copy link
Author

p5pRT commented Jun 10, 2004

From @rgs

I wrote​:

Wait, the story is not over; in recent glibcs (glibc-devel-2.3.3-12mdk)
sysmacros.h contains evil inline functions​:

\_\_extension\_\_ extern \_\_inline unsigned int
gnu\_dev\_major \(unsigned long long int \_\_dev\) \_\_THROW
\{
  return \(\(\_\_dev >> 8\) & 0xfff\) | \(\(unsigned int\) \(\_\_dev >> 32\) & ~0xfff\);
\}

and so on.

I've commited a rough patch (#22925) to bleadperl to "fix" this. It
makes the situation a bit better (and the regression tests of Sys​::Mknod
now pass on mandrake-cooker -- if Sam Vilain hears us.)

I strongly recommend that this is backported to maintperl. At least I'm
currently in the process of integrating it with the 5.8.4 that ships
with Mandrakelinux.

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