Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the File-MimeInfo CPAN distribution.

Report information
The Basics
Id: 93221
Status: resolved
Priority: 0/
Queue: File-MimeInfo

People
Owner: Nobody in particular
Requestors: chrissicool [...] googlemail.com
Cc:
AdminCc:

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



From chrissicool [...] googlemail.com Fri Feb 21 05: 31:15 2014
MIME-Version: 1.0
X-Spam-Status: No, score=-2.699 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_LOW=-0.7] autolearn=ham
X-Mailer: Evolution 3.8.4-0ubuntu1
X-Spam-Flag: NO
Content-Type: multipart/mixed; boundary="=-AgnZIrCjBOHu3egUeIZA"
Message-ID: <1392978657.1828.22.camel [...] raijin>
X-Received: by 10.15.52.66 with SMTP id o42mr7447515eew.89.1392978665046; Fri, 21 Feb 2014 02:31:05 -0800 (PST)
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Spam-Score: -2.699
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id ED540240631 for <cpan-bug+File-MimeInfo [...] hipster.bestpractical.com>; Fri, 21 Feb 2014 05:31:14 -0500 (EST)
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 rlXhmrXmYn3W for <cpan-bug+File-MimeInfo [...] hipster.bestpractical.com>; Fri, 21 Feb 2014 05:31:13 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id CCA99240615 for <bug-File-MimeInfo [...] rt.cpan.org>; Fri, 21 Feb 2014 05:31:11 -0500 (EST)
Received: (qmail 10294 invoked by alias); 21 Feb 2014 10:31:11 -0000
Received: from mail-ea0-f177.google.com (HELO mail-ea0-f177.google.com) (209.85.215.177) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Fri, 21 Feb 2014 02:31:09 -0800
Received: by mail-ea0-f177.google.com with SMTP id h10so96990eak.8 for <bug-File-MimeInfo [...] rt.cpan.org>; Fri, 21 Feb 2014 02:31:05 -0800 (PST)
Received: from [10.24.44.7] (gate.trust2core.de. [89.246.70.98]) by mx.google.com with ESMTPSA id f45sm24940902eeg.5.2014.02.21.02.31.02 for <bug-File-MimeInfo [...] rt.cpan.org> (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 21 Feb 2014 02:31:03 -0800 (PST)
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] googlemail.com
Delivered-To: cpan-bug+File-MimeInfo [...] hipster.bestpractical.com
Subject: Double-close on a filehandle
Return-Path: <chrissicool [...] googlemail.com>
X-RT-Mail-Extension: file-mimeinfo
X-Original-To: cpan-bug+File-MimeInfo [...] hipster.bestpractical.com
X-Spam-Check-BY: la.mx.develooper.com
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=message-id:subject:from:to:date:content-type:mime-version; bh=m+qKgFbqmX1IMx3YOo0MMJz/ut4Tij6KFkqfdHR76MA=; b=ldsf5rQY3wVEX0S2aSni/bXImIOoOOHy2AVKxKOV/WEdzKJ17BOa00Oxz3FLFkEEpN 8Q2y5YWvtGpGCn66974bzwvYRCi2mTzmwJWgr2owVHh59IoDZGTbOW8bnS9GzlznfEFI xZg88whxreMW+yS8DvQtJJHUm6WVTeDUBdZLgS6HjtKfy7hDS3wtXD2KcLIEa5rxiVtE pD6Q2xIGh8HRAPCtsxXFMazAldgsIGKwwyDG0bLBWJ27ImRs54swvEpq4IsgEZfKjHu8 49ykFmABE+B5ID1gFbDceAyiyweBV7agoERl5MAs004m3uldIW5lumVU/X9rU8BnGXYh oVtg==
Date: Fri, 21 Feb 2014 11:30:57 +0100
X-Spam-Level:
To: bug-File-MimeInfo [...] rt.cpan.org
From: Christian Ludwig <chrissicool [...] googlemail.com>
X-RT-Interface: Email
Content-Length: 0
content-type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
X-RT-Original-Encoding: utf-8
Content-Length: 459
Download (untitled) / with headers
text/plain 459b
I ran into the following error: Can't use an undefined value as a symbol reference at /usr/share/perl5/File/MimeInfo/Magic.pm line 46. The problem is that _magic() closes the fd when it finds a result for lower priority rules. mimetype() then tries to close it again. Since we take a completely different route in mimetype() if 'ref file' is true, we can close the fd safely whenever the low-priority rules return one. The appended patch fixes the issue.
Content-Type: text/x-patch; charset="UTF-8"; name="magic.patch"
Content-Disposition: attachment; filename="magic.patch"
Content-Transfer-Encoding: 7bit
X-RT-Original-Encoding: utf-8
Content-Length: 413
Download magic.patch
text/x-diff 413b

Message body is not shown because sender requested not to inline it.

MIME-Version: 1.0
In-Reply-To: <1392978657.1828.22.camel [...] raijin>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <1392978657.1828.22.camel [...] raijin>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-23208-1393188656-98.93221-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 798
Download (untitled) / with headers
text/plain 798b
On Fri Feb 21 05:31:16 2014, chrissicool@googlemail.com wrote: Show quoted text
> I ran into the following error: > > Can't use an undefined value as a symbol reference at > /usr/share/perl5/File/MimeInfo/Magic.pm line 46. > > The problem is that _magic() closes the fd when it finds a result for > lower priority rules. mimetype() then tries to close it again. > > Since we take a completely different route in mimetype() if 'ref file' > is true, we can close the fd safely whenever the low-priority rules > return one.
Hi Chris, Thanks for your bug report. Would you be able to supply a test case? I'm thinking it might be better to not close the file handle we're returning in _magic() on line 78, do you agree? https://github.com/mbeijen/File-MimeInfo/blob/master/lib/File/MimeInfo/Magic.pm#L78 -- Mike
From chrissicool [...] googlemail.com Wed Feb 26 16: 59:47 2014
MIME-Version: 1.0
X-Spam-Status: No, score=-2.699 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_LOW=-0.7] autolearn=ham
In-Reply-To: <rt-4.0.18-23208-1393188657-1542.93221-6-0 [...] rt.cpan.org>
X-Mailer: Evolution 3.8.4-0ubuntu1
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-93221 [...] rt.cpan.org> <1392978657.1828.22.camel [...] raijin> <rt-4.0.18-23208-1393188657-1542.93221-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Received: by 10.14.105.200 with SMTP id k48mr9357762eeg.44.1393451978290; Wed, 26 Feb 2014 13:59:38 -0800 (PST)
Message-ID: <1393451976.2780.31.camel [...] raijin>
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -2.699
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] googlemail.com
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 9BAD824046A for <cpan-bug+File-MimeInfo [...] hipster.bestpractical.com>; Wed, 26 Feb 2014 16:59:47 -0500 (EST)
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 Mr6zptNshEqs for <cpan-bug+File-MimeInfo [...] hipster.bestpractical.com>; Wed, 26 Feb 2014 16:59:46 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id C42C7240358 for <bug-File-MimeInfo [...] rt.cpan.org>; Wed, 26 Feb 2014 16:59:45 -0500 (EST)
Received: (qmail 16946 invoked by alias); 26 Feb 2014 21:59:44 -0000
Received: from mail-ee0-f53.google.com (HELO mail-ee0-f53.google.com) (74.125.83.53) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 26 Feb 2014 13:59:42 -0800
Received: by mail-ee0-f53.google.com with SMTP id c13so920586eek.12 for <bug-File-MimeInfo [...] rt.cpan.org>; Wed, 26 Feb 2014 13:59:38 -0800 (PST)
Received: from ?IPv6:2003:46:b56:2e37:f129:4ba3:70d7:4ecf? ([2003:46:b56:2e37:f129:4ba3:70d7:4ecf]) by mx.google.com with ESMTPSA id x6sm8902993eew.20.2014.02.26.13.59.37 for <bug-File-MimeInfo [...] rt.cpan.org> (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 26 Feb 2014 13:59:37 -0800 (PST)
Delivered-To: cpan-bug+File-MimeInfo [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #93221] Double-close on a filehandle
Return-Path: <chrissicool [...] googlemail.com>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=message-id:subject:from:to:date:in-reply-to:references:content-type :mime-version:content-transfer-encoding; bh=jlVbzR0ocvTLw2uE6wNDv5XmgbEuwJoGqiBju1Is2Sc=; b=gzJqrFvJwEwpRSNVetZyHbBo1zBmDHbmbne6at7YCCOdyALBMpt40cHt08TQLmGzRF PhugAyxU57fJsh579lmnaMfaV0RIhFBVINlpY5myk2oTFR88JEx8cAWWIh8uAnetENV3 Tm9eRwMHfwWjyRBN64OA9K6/Y2hOhA9m0i2DJTPvesaGXbxuhOSRUbNKyEtihuGZMK3V V+33F1TYy4gOov7ERCb4GcmU9jO79FqD0wLomQ7VyONn4LHx3l8iadbHOIh7nLgfEqWo O0dMfzI3vGF2A6EkUkGjf7b00cKFOXePFygJGKTogYOr17uh5JfPUDn264IeajXeS4NR BywA==
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+File-MimeInfo [...] hipster.bestpractical.com
X-RT-Mail-Extension: file-mimeinfo
Date: Wed, 26 Feb 2014 22:59:36 +0100
X-Spam-Level:
To: bug-File-MimeInfo [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Christian Ludwig <chrissicool [...] googlemail.com>
RT-Message-ID: <rt-4.0.18-32556-1393451988-176.93221-0-0 [...] rt.cpan.org>
Content-Length: 1111
Hi, On So, 2014-02-23 at 15:50 -0500, Michiel Beijen via RT wrote: Show quoted text
> Thanks for your bug report. Would you be able to supply a test case?
In my setup, I see that error only for files of type application/octet-stream. Then I saw that there is no test for the default file types. Please find my tests on GitHub at [1]. Confusingly enough the tests all pass. Granted, my setup is a little more complicated. I am running threaded Perl using async workers. That triggers the problem "every now and then". Show quoted text
> I'm thinking it might be better to not close the file handle we're returning in _magic() on line 78, do you agree? > https://github.com/mbeijen/File-MimeInfo/blob/master/lib/File/MimeInfo/Magic.pm#L78
In my opinion it should better be the other way around. Why not close the file in _magic() again? And if you don't ant to re-open the same file multiple times, perhaps make _magic() only handle fd refs. I think it's easier to read when calls to open() and close() are in the same function. [1] https://github.com/chrissicool/File-MimeInfo/commit/ff684d3f27f16b81dd17355d5ef582b082465d12 - Christian
MIME-Version: 1.0
In-Reply-To: <1392978657.1828.22.camel [...] raijin>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <1392978657.1828.22.camel [...] raijin>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-22412-1393534429-968.93221-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 115
Download (untitled) / with headers
text/plain 115b
Thanks for your reporting and fixing this issue! I've included your patch & fix and released 0.22 to CPAN. -- Mike


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.