Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Data-Dumper CPAN distribution.

Report information
The Basics
Id: 128681
Status: open
Priority: 0/
Queue: Data-Dumper

People
Owner: XSAWYERX [...] cpan.org
Requestors: pause [...] tlinx.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.173
Fixed in: (no value)



Subject: the XS version doesn't work w/my code when pureperl does.
Have an util that goes back to 2012. It trims duplicate versions of downloaded RPMS and saves the latest. Using pure perl, output looks like: Show quoted text
> remove-oldver-rpms-in-dir.pl
Read 32742 rpm names. Use 9 procs w/3639 items/process #pkgs=20864, #deletes=11878, total=32742 1 additional duplicates found in last pass Recycling 11879 duplicates...Done Cumulative This Phase ID 0.000s 0.000s Init 0.000s 0.000s start_program 0.230s 0.230s starting_children 0.233s 0.003s end_starting_children 276.811s 276.578s endRdFrmChldrn_n_start_re_sort 337.756s 60.945s afterFinalSort 340.943s 3.187s afterRecycle It splits up the task and divides it among multiple processes. To read the data structs in from the children, they dump the data they worked on and the paran evals the data back in. The XS version gives: Show quoted text
h> remove-oldver-rpms-in-dir.pl
Read 42 rpm names. Use 1 procs w/24 items/process Error in evaluating data: Global symbol "%Data" requires explicit package name at /home/law/bin/remove-oldver-rpms-in-dir.pl line 469, <$mfrh> line 1. syntax error at /home/law/bin/remove-oldver-rpms-in-dir.pl line 469, near "# line 469 /home/law/bin/remove-oldver-rpms-in-dir.pl %Data[" at /home/law/bin/remove-oldver-rpms-in-dir.pl line 472, <$mfrh> line 1. main::read_slave(1, GLOB(0xa97d80), Parse_n_Cmp=HASH(0xa9e310), undef) called at /home/law/bin/remove-oldver-rpms-in-dir.pl line 590 main::read_data_from_children(main=HASH(0x61f210)) called at /home/law/bin/remove-oldver-rpms-in-dir.pl line 705 "Data" should have been an array (@Data). I did try recompiling D::D just in case something was out of date -- no change. Attached is some sample data that I eval in the parent when it collects from the child. Also is the source of the program. Dbg isn't needed (I don't think). I think any other modules are in cpan. This does work in pureperl, so I have that option on a separate line not too far from the top to comment out or not. Also, I'm not in a hurry to get a solution, since I can use the perl version though it is a bit slower... :-) Any Questions, be sure to ask. Linda
Subject: CompVer.pm
#!/usr/bin/perl # gvim=:SetNumberAndWidth use warnings; use strict; ################################################################################ { package TypeVal; use warnings; use strict; use mem; use Data::Vars [qw(type val)]; 1} ################################################################################ { package CompVer; use warnings; use strict; our $VERSION='0.0.1'; use mem; use P; our @EXPORT; use mem (@EXPORT = qw(cmp_vers)); use Xporter; use constant { date => 100, num => 75, string => 50, colon => 4, dash => 4, dot => 3, }; sub parse_ver ($) { local $_ = $_[0]; my (@result, $t); sub addtok; local *addtok = sub { push @result, TypeVal->new({type => $t, val => $1 }); $_ = $2; }; while (length) { /^(2\d{7})(.*)$/ and $t=date, addtok, next; /^(\d+)(\W.*)$/ and $t=num, addtok, next; /^(\d+)$/ and $t=num, addtok, next; /^(\.)(.*)$/ and $t=dot, addtok, next; /^([-_])(.*)$/ and $t=dash, addtok, next; /^(:)(.*)$/ and $t=colon, addtok, next; /^([^_\.:-]+)(.*)$/ and $t=string, addtok, next; /^(.+)$/ and $t=string, addtok, next; } return @result; } ## end sub parse_ver ($) sub cmp_vers($$) { my ($va, $vb) = @_; my @pa = parse_ver("$va"); my @pb = parse_ver("$vb"); for (my $i = 0 ; $i < @pa ; ++$i) { return -1 if $i > @pb; my ($pat, $pav) = @{$pa[$i]}{qw(type val)}; my ($pbt, $pbv) = @{$pb[$i]}{qw(type val)}; my $cmp; return $cmp if ($pat >= num && $pbt >= num and $cmp = $pav <=> $pbv) or $cmp = $pav cmp $pbv; } # getting here means at end of pa array; # if we still have more in pb array then it is longer (and greater) return @pb > @pa ? 1 : 0; } 1}
Subject: RecycleBin.pm
#!/usr/bin/perl { package RecycleBin; use warnings; use strict; use P; use PathCat qw(Sep); use Cwd; my $max_warn = 1; my $warnings = 0; # gvim=:SetNumberAndWidth sub getdev_n_path($) { my $path = $_[0]; my $dev = (stat $path)[0]; return ($dev, $path); # my $retry=0; # if ($path =~ m{noarch\.rpm$} ) { # $path=~ s/noarch\.rpm/src.rpm/; $retry=1 ; # } elsif ($path =~ m{src\.rpm$} ) { # $path=~ s/src\.rpm/noarch.rpm/; $retry=1; # } # # if ($retry) { # ($dev = (stat $path)[0]) and do { # return ($dev, $path); # }; # } # return undef; } sub get_partname($) { my $dev = $_[0]; my ($devmaj, $devmin) = ($dev >> 8, $dev & 0xff); my $devpath = "/sys/dev/block/$devmaj:$devmin"; my $devname; my ($partname, $partRE); if (-d pathcat($devpath, "dm")) { open(my $ph, "<", "/sys/dev/block/$devmaj:$devmin/dm/name") || die "can't open volume name: $!\n"; $partname = <$ph>; chomp $partname; $partRE = $partname; while ($partRE =~ m{\w-\w}) { $partRE =~ s{(\w)-(\w)}{$1.'[-/]'.$2}e; } } else { my $part = readlink $devpath; $partname = ($part =~ m{([^/]+)$}) ? $1 : undef; unless ($partname) { warn "Cannot get partion name from devpath link"; return (undef, undef); } $partname = "/dev/" . $partname; $partRE = $partname; } ($partname, $partRE) } sub get_mnt_point ($) { my $partname = $_[0]; open(my $mh, "<", "/proc/mounts") or die "Can't open /proc/mount: $?\n"; my @table = <$mh>; my @mps = grep m{$partname}, @table; die "Cannot find $partname in mount table" if @mps < 1; my $mnt_pnt = (split /\s+/, $mps[0])[1]; chomp $mnt_pnt; $mnt_pnt; } sub get_recycle_bin($) { my $mnt_pnt = $_[0]; my $recycle_bin; umask 0; if (!-d ($recycle_bin = pathcat($mnt_pnt, ".recycle"))) { mkdir ($recycle_bin, 01777) || die "Cannot create recycle bin under mount $mnt_pnt: $!"; chmod 01777, $recycle_bin || die "Cannot set correct mode:$!"; } $recycle_bin; } sub createdest($$) {my ($voldir, $dest) = @_; umask 0; use Cwd qw(abs_path); my @parts = split '/', $dest; my $curdir = abs_path(); chdir $voldir || die "Cannot create path for recycling @ $voldir"; while (@parts) { $voldir = pathcat($voldir, shift @parts); if (! -d $voldir) { mkdir ($voldir, 01777) || die "Cannot create path @ $voldir: $!"; chmod 01777, $voldir; chdir $voldir; } } chdir $curdir; } our (%dev2partname, %partition2mntpt, %mntdir2recycle); sub recycle_warn($) { my $msg=$_[0]; ++$warnings; if (--$max_warn) { warn $msg;return undef; } else { die $msg}; } sub recycle ($) { my $path = Sep eq substr($_[0],0,1) ? $_[0] : pathcat(getcwd,$_[0]); my ($dev, $real_path) = getdev_n_path($path); #/local/suse/tumbleweed/repo/src-non-oss/suse #/ (src) (7kaa-music-20140929-1.11) .(noarch).rpm # unless ($dev && $real_path) { # my ($dirs,$file, $rpmtype, $sfx) = m{^(.*?)/([^/]+?)/([^/.]+?)\.([^/.]+)$}; # Pe "dr=%s, fl=%s, rt=%s, sfx=%s", $dirs,$file, $rpmtype, $sfx; # my $newpath="$dirs/$file."; # } return recycle_warn( P "real_path=%s(%s), dev=%s", $real_path, ($real_path && -e $real_path? "exists" : "Nexist"), $dev) unless $dev && $real_path; my ($partname, $partRE) = $dev2partname{$dev} ||= get_partname($dev); die "Can't get partname (?$partname?) from dev ($dev)" unless $partname; my $mnt_pnt = $partition2mntpt{$partname} ||= get_mnt_point($partname); die "Can't get mntpnt (4 partname $partname)" unless $mnt_pnt; my $recycle_bin = $mntdir2recycle{$mnt_pnt} ||= get_recycle_bin($mnt_pnt); my $file = ($real_path =~ m{.*/([^/]+)$})[0]; my $src = $real_path; $real_path =~ s{$mnt_pnt/}{}; #sub path in recycle bin my $path_recycle_dir = ($real_path =~ m{(.*)/[^/]+$} ) [0]; my $dst = pathcat($recycle_bin, $path_recycle_dir, $file); my $recycle_target_dir = pathcat($recycle_bin, $path_recycle_dir); createdest($recycle_bin, $path_recycle_dir) unless -d $recycle_target_dir; die P "FAIL -- no target dir %s, in mntpt %s", $recycle_target_dir, $mnt_pnt unless -d $recycle_target_dir; if (link $src, $dst) { unlink $src or recycle_warn( P "Could not unlink old file %s", $src); } else { recycle_warn(P "Could not link %s into %s", $src, $recycle_bin); } return !$warnings; } ## end sub recycle ($) 1} ## vim: ts=2 sw=2 ai
Subject: remove-oldver-rpms-in-dir.pl

Message body is not shown because it is too large.

Subject: tmpdata-0
Download tmpdata-0
application/octet-stream 329.3k

Message body not shown because it is not plain text.

BTW, this is in perl 5.16.3: Summary of my perl5 (revision 5 version 16 subversion 3) configuration: Platform: osname=linux, osvers=3.12.0-isht-van, archname=x86_64-linux-thread-multi-ld uname='linux ishtar 3.12.0-isht-van #1 smp preempt wed nov 13 16:50:51 pst 2013 x86_64 x86_64 x86_64 gnulinux ' config_args='' hint=previous, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=define usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-g -O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' ccversion='', gccversion='4.8.1 20130909 [gcc-4_8-branch revision 202388]', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='long double', nvsize=16, Off_t='off_t', lseeksize=8 alignbytes=16, prototype=define Linker and Libraries: ld='gcc', ldflags ='-g -fstack-protector -fPIC' libpth=/usr/lib64 /lib64 libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.18.so, so=so, useshrplib=true, libperl=libperl-5.16.3.so gnulibc_version='2.18' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/home/perl/perl-5.16.3/lib/x86_64-linux-thread-multi-ld/CORE' cccdlflags='-fPIC', lddlflags='-shared -g -O2 -fstack-protector -fPIC' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP PERL_PRESERVE_IVUV 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_LONG_DOUBLE USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API Built under linux Compiled at Jan 23 2014 00:35:49 %ENV: PERL5OPT="-Mutf8 -CSA -I/home/law/bin/lib" @INC: /home/law/bin/lib /home/perl/perl-5.16.3/lib/site/x86_64-linux-thread-multi-ld /home/perl/perl-5.16.3/lib/site /home/perl/perl-5.16.3/lib/x86_64-linux-thread-multi-ld /home/perl/perl-5.16.3/lib Also -- attaching a sample directory that this would use as input (a smallish directory), though it probably isn't practical for me to submit the actual rpms behind this directory (2.5G) They are from the SuSE tumbleweed distribution.
Subject: src-inp.txt
7kaa-music-20140929-1.16.src.rpm 7kaa-music-20140929-1.17.src.rpm AdobeICCProfiles-2.0-155.13.src.rpm AdobeICCProfiles-2.0-155.14.src.rpm Reaction-1.0-1.51.src.rpm Reaction-1.0-1.58.src.rpm Reaction-1.0-1.61.src.rpm Reaction-data-1.0-1.10.src.rpm Reaction-data-1.0-1.9.src.rpm THE-3.3~RC4-4.35.src.rpm THE-3.3~RC4-5.4.src.rpm THE-3.3~RC4-5.7.src.rpm bpg-fonts-0.20120510-192.16.src.rpm bpg-fonts-0.20120510-192.17.src.rpm bpg-fonts-0.20120510-192.18.src.rpm cg-3.1.0013-8.59.src.rpm cg-3.1.0013-8.61.src.rpm cg-3.1.0013-8.63.src.rpm discord-0.0.5-1.1.src.rpm discord-0.0.8-1.1.src.rpm discord-0.0.8-1.2.src.rpm frogatto-1.3.1-4.23.src.rpm frogatto-1.3.1-4.33.src.rpm frogatto-1.3.1-4.36.src.rpm iozone-3.471-1.12.src.rpm iozone-3.483-1.2.src.rpm iozone-3.483-1.5.src.rpm ivtv-firmware-1.4.0-3.16.src.rpm ivtv-firmware-1.4.0-3.17.src.rpm john-wordlists-1-6.13.src.rpm john-wordlists-1-6.14.src.rpm mikachan-fonts-9.1.2006.08.09-174.46.src.rpm mikachan-fonts-9.1.2006.08.09-174.47.src.rpm mikachan-fonts-9.1.2006.08.09-174.48.src.rpm moneyplex-12.0.20869-8.25.src.rpm moneyplex-12.0.20869-8.26.src.rpm netperf-2.7.0-1.54.src.rpm netperf-2.7.0-1.58.src.rpm netperf-2.7.0-1.60.src.rpm openSUSE-Addon-NonOss-release-20190121-9.1.src.rpm openSUSE-Addon-NonOss-release-20190209-40.1.src.rpm openttd-opensfx-0.2.3-8.15.src.rpm openttd-opensfx-0.2.3-8.16.src.rpm opera-54.0.2952.41-1.1.src.rpm opera-57.0.3098.116-1.1.src.rpm opera-58.0.3135.47-1.1.src.rpm patterns-non_oss-20170319-1.3.src.rpm patterns-non_oss-20170319-1.4.src.rpm perlref-5.004.1-7.7.src.rpm snipl-0.3.0.0-3.13.src.rpm snipl-0.3.0.0-3.19.src.rpm snipl-0.3.0.0-3.20.src.rpm steam-1.0.0.54-5.4.src.rpm steam-1.0.0.59-1.1.src.rpm steamcmd-0.20160905-2.1.src.rpm steamcmd-0.20160905-2.2.src.rpm stream-5.10-2.6.src.rpm stream-5.10-2.7.src.rpm stream-5.10-2.9.src.rpm unrar-5.6.5-1.6.src.rpm unrar-5.6.8-1.4.src.rpm unrar-5.7.1-1.3.src.rpm xv-3.10a-1297.27.src.rpm xv-3.10a-1297.32.src.rpm xv-3.10a-1297.36.src.rpm
This is a huge amount of code. Is it possible to boil it down to something small that still reproduces the issue?
Subject: Re: [rt.cpan.org #128681] the XS version doesn't work w/my code when pureperl does.
Date: Fri, 01 Mar 2019 17:08:32 -0800
To: bug-Data-Dumper [...] rt.cpan.org
From: "L. A. Walsh" <pause [...] tlinx.org>
On 3/1/2019 3:14 PM, Karen Etheridge via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=128681 > > > This is a huge amount of code. Is it possible to boil it down to something small that still reproduces the issue? >
---- Like I said, 1) it's a new error. I last ran the script in Sep of last year. 2) it doesn't happen in the pure perl version. 3) I have a workaround using the perl version 4) The package dumps output in "sub start_childrenQs @ #395-430 where it says "$package_p->dump_to_output". That calls Dump_SO (dump to standard out). That calls SDump right above it in package "DDump @ #42. Immediately below start_childrenQs is 'read_slave -- used by the mother of the children to slurp the data in and eval it. which is where the failure occurs (in the eval). I.e. the code dumped out by the children shows a $Data["0"]=<all the data>. I.e. Data is an array (yes I tried it without the quotes). @Data i/s /declared just before the eval, but the error message says something about looking for a %Data. Why it is looking for a hash rather than array is the problem/different between the xs/perl versions. Have you tried running the test case? The line to toggle is in the DDump package(#42) at line 52, where 'Useperl(1)->' is on a line by itself. As it is, it calls Useperl(1), but commented out it will default to the 'xs' version. I tried to include everything needed to reproduce the bug. But as far as narrowing down the bug in Data::Dumper with a small test case, I know its time I don't have. FWIW, the constant 'save_intermediate set to (1) uses tmp files to communicate between children+mother in /dev/shm/tmp/. Otherwise it uses sockets. You don't have to follow everything. If I was debugging it, I might save the intermediate files in the perl vs. xs case, and compare them. That'd be my first step. I almost didn't report it because that took up quite a bit of time by itself, but it is a clearly a bug that only is visible when the 'xs' module is used and due to some change since last fall. (assuming xs was the default before then). If the 'xs' had just been added, I'd point fingers at that, but that doesn't seem to be the case. Let me know if you have a problem running it, but I really tried to put everything needed there. Cheers!