Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Path-Class CPAN distribution.

Maintainer(s)' notes

I prefer that bugs & patches are filed on GitHub rather than on RT: https://github.com/kenahoo/Path-Class/issues. Thanks.

Report information
The Basics
Id: 83880
Status: open
Priority: 0/
Queue: Path-Class

People
Owner: Nobody in particular
Requestors: ediap [...] wp.pl
Cc:
AdminCc:

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



From ediap [...] wp.pl Mon Mar 11 09: 49:20 2013
MIME-Version: 1.0
X-Spam-Status: No, score=-6.998 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_HI=-5, SPF_FAIL=0.001] autolearn=ham
X-Spam-Flag: NO
X-WP-Spam: NO 0000000 [8fM0]
content-type: text/plain; charset="utf-8"
Message-ID: <513DE0BE.4080509 [...] wp.pl>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Spam-Score: -6.998
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 6A7A52406D7 for <cpan-bug+Path-Class [...] hipster.bestpractical.com>; Mon, 11 Mar 2013 09:49:20 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Jqcg4t6ph+ge for <cpan-bug+Path-Class [...] hipster.bestpractical.com>; Mon, 11 Mar 2013 09:49:15 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 51CA22405D5 for <bug-Path-Class [...] rt.cpan.org>; Mon, 11 Mar 2013 09:49:14 -0400 (EDT)
Received: (qmail 5095 invoked by uid 103); 11 Mar 2013 13:49:13 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 11 Mar 2013 13:49:13 -0000
Received: from mx3.wp.pl (HELO mx3.wp.pl) (212.77.101.7) by 16.mx.develooper.com (qpsmtpd/0.84/v0.84-167-g4ed6cab) with ESMTP; Mon, 11 Mar 2013 06:49:05 -0700
Received: (wp-smtpd smtp.wp.pl 7805 invoked from network); 11 Mar 2013 14:48:51 +0100
Received: from nat-dem.mentorg.com (HELO [137.202.40.176]) (ediap [...] [195.212.93.2]) (envelope-sender <ediap [...] wp.pl>) by smtp.wp.pl (WP-SMTPD) with CAMELLIA256-SHA encrypted SMTP for <bug-Path-Class [...] rt.cpan.org>; 11 Mar 2013 14:48:51 +0100
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] wp.pl
Delivered-To: cpan-bug+Path-Class [...] hipster.bestpractical.com
Subject: [Path::Class:File] slurp() method does not close file handle prior returning
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3
Return-Path: <ediap [...] wp.pl>
X-RT-Mail-Extension: path-class
X-Original-To: cpan-bug+Path-Class [...] hipster.bestpractical.com
X-Spam-Check-BY: 16.mx.develooper.com
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1363009731; bh=HP3NnR/9i1JXNBjC60mYqzy59EGX0BJKBehwQrsTtt8=; h=From:To:Subject; b=MCBoPMriM8ssuUoI+QyMzRlN3uQdoXeit4MDyCWzaHfUT5ilgxtDmLWefnGwgyVPL DAAYZxSQiotvXkKavgc+wHzIpSRnnM115AmIA6DyFm5CgH426PB09IokaPAel4ewqR O8vhUXUKyxydouTYLNQT/3HQhFS0pFPNyRW7nQ+M=
Date: Mon, 11 Mar 2013 14:48:46 +0100
X-WP-Av: skaner antywirusowy poczty Wirtualnej Polski S. A.
X-Spam-Level:
To: bug-Path-Class [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Adam Piątyszek <ediap [...] wp.pl>
X-RT-Original-Encoding: us-ascii
Content-Length: 395
Download (untitled) / with headers
text/plain 395b
Hi, It seems that the slurp() method of Path::Class::File does not close the file handle created with $self->open($iomode). This causes problems with removal of a directory containing the just slurped file with Path::Class::Dir->rmtree(). A simple fix should be to just add: "$fh->close;" after: my @data = <$fh>; and chomp( my @data = <$fh> ); lines of the slurp() method. Thanks, /Adam
MIME-Version: 1.0
In-Reply-To: <513DE0BE.4080509 [...] wp.pl>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <513DE0BE.4080509 [...] wp.pl>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-7141-1363011156-1076.83880-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 209
Download (untitled) / with headers
text/plain 209b
Thanks Adam. By opening $fh the way we do, it should automatically be closed when it goes out of scope, which is preferable to manually closing. Do you have an example that demonstrates the problem? -Ken
From ediap [...] wp.pl Mon Mar 11 10: 41:06 2013
MIME-Version: 1.0
X-Spam-Status: No, score=-6.998 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_HI=-5, SPF_FAIL=0.001] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-7141-1363011157-888.83880-6-0 [...] rt.cpan.org>
X-Spam-Flag: NO
X-WP-Spam: NO 0000000 [IQOU]
References: <RT-Ticket-83880 [...] rt.cpan.org> <513DE0BE.4080509 [...] wp.pl> <rt-3.8.HEAD-7141-1363011157-888.83880-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <513DECF0.20005 [...] wp.pl>
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -6.998
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] wp.pl
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id B07562405D5 for <cpan-bug+Path-Class [...] hipster.bestpractical.com>; Mon, 11 Mar 2013 10:41:06 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tfdi9N6oIbbu for <cpan-bug+Path-Class [...] hipster.bestpractical.com>; Mon, 11 Mar 2013 10:41:05 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id BECC4240708 for <bug-Path-Class [...] rt.cpan.org>; Mon, 11 Mar 2013 10:41:04 -0400 (EDT)
Received: (qmail 8683 invoked by uid 103); 11 Mar 2013 14:41:04 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 11 Mar 2013 14:41:04 -0000
Received: from mx4.wp.pl (HELO mx4.wp.pl) (212.77.101.8) by 16.mx.develooper.com (qpsmtpd/0.84/v0.84-167-g4ed6cab) with ESMTP; Mon, 11 Mar 2013 07:40:56 -0700
Received: (wp-smtpd smtp.wp.pl 23537 invoked from network); 11 Mar 2013 15:40:50 +0100
Received: from nat-dem.mentorg.com (HELO [137.202.40.176]) (ediap [...] [195.212.93.2]) (envelope-sender <ediap [...] wp.pl>) by smtp.wp.pl (WP-SMTPD) with CAMELLIA256-SHA encrypted SMTP for <bug-Path-Class [...] rt.cpan.org>; 11 Mar 2013 15:40:50 +0100
Delivered-To: cpan-bug+Path-Class [...] hipster.bestpractical.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3
Subject: Re: [rt.cpan.org #83880] [Path::Class:File] slurp() method does not close file handle prior returning
Return-Path: <ediap [...] wp.pl>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1363012850; bh=ujinRbXMd7t5ILTeM6FlMPdOM6t12wrSAE+Mkz+kO8w=; h=From:To:Subject; b=xU+/aG62bXded3ulSThw3ksf9rhb4/d3ERnEV9QOpyI5evz9373xcePproWVzVpxx 4ca8ywK9VmeCkVUNtvBEjrVXDMoWpfsTRmq3t5UC4cCBu/KhkOwQ3o3dlv89tyIuxC 89Psv8JBsIvedN8OJnnFAb28Ygaqth1OAOUDrP4U=
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+Path-Class [...] hipster.bestpractical.com
X-RT-Mail-Extension: path-class
Date: Mon, 11 Mar 2013 15:40:48 +0100
X-WP-Av: skaner antywirusowy poczty Wirtualnej Polski S. A.
X-Spam-Level:
To: bug-Path-Class [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Adam Piątyszek <ediap [...] wp.pl>
RT-Message-ID: <rt-3.8.HEAD-30428-1363012867-1092.83880-0-0 [...] rt.cpan.org>
Content-Length: 1746
Download (untitled) / with headers
text/plain 1.7k
* Ken Williams via RT [03/11/2013 03:12 PM]: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=83880 > > > Thanks Adam. > > By opening $fh the way we do, it should automatically be closed when it > goes out of scope, which is preferable to manually closing. Do you have > an example that demonstrates the problem?
Hi Ken, The problem was with my production code running in NFS environment, thus I am not sure if I will be able to crate a minimum testcase showing this on a local disk. The code was doing something like this: my $directory_with_files = Path::Class::Dir( <some directory> ); while ( my $file = $directory_with_files->next ) { # skip anything but *.file next if substr( $file->stringify, -5, 5 ) ne '.file'; my @lines = $file->slurp( chomp => 1 ); # here process the @lines array } # system("ls -la $directory_with_files"); $directory_with_files->rmtree; # system("ls -la $directory_with_files"); The error was coming from the File::Path module. I debugged this by listing the files with the shell 'ls -la' command and one of the files being opened was renamed to ".nfs<some_random_number_here>", which means that the file was still open while the removal operation was in progress. The $file->slurp() operation was the only thing that was opening these files. When I changed the code like this, it started to work without any problems: while ( my $file = $directory_with_files->next ) { # skip anything but *.file next if substr( $file->stringify, -5, 5 ) ne '.file'; my $fh = $file->openr; foreach my $line (<$fh>) { # here process the lines of each file } $fh->close; } $directory_with_files->rmtree; I will try to send you a real case and it's output on an NFS filesystem later today. Thanks, /Adam


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.