Skip Menu |

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

Report information
The Basics
Id: 46477
Status: open
Priority: 0/
Queue: File-MMagic

People
Owner: Nobody in particular
Requestors: rjbs [...] cpan.org
Cc:
AdminCc:

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



Subject: re-seeking on DATA fh can fail, with bizarre results
Sometimes when there is forking or other stuff going on, calling File::MMagic->new will try reading the code of the library instead of the DATA section. Re-seeking DATA is often a big pain. I fixed my local copy by patching to cache the contents of the data section. -- rjbs
On Fri May 29 14:27:29 2009, RJBS wrote: Show quoted text
> Sometimes when there is forking or other stuff going on, calling > File::MMagic->new will try reading the code of the library instead of > the DATA section. Re-seeking DATA is often a big pain. > > I fixed my local copy by patching to cache the contents of the data
section. Attached a script which may (sometimes) reproduce the problem. The "good" case produces output like image/gif at /tmp/fmmagic.pl line 12. 47567 at /tmp/fmmagic.pl line 13, <DATA> line 296. image/gif at /tmp/fmmagic.pl line 16. 47567 at /tmp/fmmagic.pl line 17, <DATA> line 296. But sometimes it's image/gif at /tmp/fmmagic.pl line 12. 47567 at /tmp/fmmagic.pl line 13, <DATA> line 296. application/octet-stream at /tmp/fmmagic.pl line 16. 48572 at /tmp/fmmagic.pl line 17, <DATA> line 349. or even Bad Offset/Type at line 132. '------ ' application/octet-stream at /tmp/fmmagic.pl line 16. image/gif at /tmp/fmmagic.pl line 12. 47567 at /tmp/fmmagic.pl line 13, <DATA> line 296. 45879 at /tmp/fmmagic.pl line 17, <DATA> line 270. Regards, Slaven
Subject: fmmagic.pl
#!/usr/bin/perl use strict; use warnings; use File::MMagic; my $testbuf = "GIF87a\0\1\2\3"; if (fork == 0) { my $fm1 = File::MMagic->new; warn $fm1->checktype_contents($testbuf); warn tell(File::MMagic::DATA); } else { my $fm2 = File::MMagic->new; warn $fm2->checktype_contents($testbuf); warn tell(File::MMagic::DATA); }