This queue is for tickets about the MIDI-Perl CPAN distribution.

Report information
The Basics
Id:
64049
Status:
stalled
Priority:
Low/Low
Queue:

People
Owner:
CONKLIN [...] cpan.org
Requestors:
njh [...] bandsman.co.uk
Cc:
AdminCc:

BugTracker
Severity:
Important
Broken in:
0.82
Fixed in:
(no value)



Subject: Error on close
MIDI::Opus often fails with this: error while closing filehandle for /tmp/C_lEGzBDaq.midi: "Bad file descriptor" This is the type of use: unlink('/tmp/xxx.mp3'); } elsif($url =~ /\.midi?$/i) { my $tmp = File::Temp->new(UNLINK => 1, SUFFIX => '.midi'); open(my $midi, '>', $tmp); # Extract all text fields from the MIDI file and spider them # print "MIDI $url\n"; print $midi $$contentref; close $midi; my $opus = MIDI::Opus->new({'from_file' => $tmp, 'no_parse' => 0}); foreach my $track ($opus->tracks) { foreach my $event ($track->events) { my $type = @$event[0]; if($type =~ /(text|name)/) { my $text = @$event[2]; foreach (split(/\W/, $text)) { my $word = prepareWord($_); unless(ignoreWord($word)) { # unless($matches{$word}) { # print "MIDI: found word '$word'\n"; $matches{$word} = 1; # } } } } } } $matches{'midi'} = 1;
From: njh@bandsman.co.uk
On 23/12/10 09:58, conklin@cpan.org wrote:
Show quoted text
> > Hello, > > I do not have enough information to find or address the bug you report. >
>> MIDI::Opus often fails with this: >> >> error while closing filehandle for /tmp/C_lEGzBDaq.midi: "Bad file >> descriptor"
> > at what line of your attached code does this happen? (also see
question below).
Show quoted text
>
>> This is the type of use: >> >> unlink('/tmp/xxx.mp3'); >> } elsif($url =~ /\.midi?$/i) { >> my $tmp = File::Temp->new(UNLINK => 1, SUFFIX => '.midi'); >> open(my $midi, '>', $tmp); >> # Extract all text fields from the MIDI file and spider them >> >> # print "MIDI $url\n"; >> print $midi $$contentref; >> >> close $midi;
> > is the line above where the error is happening? if so, it is not an
error with MIDI::Opus
Show quoted text
> > or, presumably you've left out code above that populates the file
$tmp, as the Opus->new below shouldn't be passed an empty midi file...? The code "print $midi $$contentref" populates the file. It is not empty. It fails in this line:
Show quoted text
>
>> my $opus = MIDI::Opus->new({'from_file' => $tmp, >> 'no_parse' => 0});
Show quoted text
> It fails in this line:
>>
>>> my $opus = MIDI::Opus->new({'from_file' => $tmp, >>> 'no_parse' => 0});
I am unable to replicate your bug. I isolated part of your code and read myself into $$contentref the contents of a test midi file (line with "***"), and the code below runs (does not fail in the Opus->new), and also dumps the expected contents. Can you try this?: my $tmp = File::Temp->new(UNLINK => 1, SUFFIX => '.midi'); open(my $midi, '>', $tmp); # Extract all text fields from the MIDI file and spider them # print "MIDI $url\n"; $contentref = "somevar"; open(X,"x.mid"); binmode(X); read(X,$$contentref,10000); close(X); # *** print $midi $$contentref; close $midi; my $opus = MIDI::Opus->new({'from_file' => $tmp, 'no_parse' => 0}); $opus->dump({dump_tracks=>1}); But the code above should also produce an error in that case. Therefore the fix of this bug is stalled until the error can be reproduced. Actually, from reading the File::Temp docs I suspect the problem is some interaction with File::Temp which in addition to a filename also opens and returns a filehandle (therefore your handling of return values from the File::Temp->new() is not accurate). Can you (in your own code) try to replace the File::Temp->new(...) line by my $tmp = File::Temp->tmpnam(); Does your code still die?


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

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