Re: Bad free() with perl, DBI, Informix and blobs
Posted in 1998
On 2 Dec 1998, Tim Potter wrote: > "Steven Primrose-Smith" <smith@avl.com> writes: > > > After much playing about, I finally managed to get blobs > > in and out of an Informix database using DBI. However, > > there is a problem. I have a function that returns the blob > > as a scalar. Whenever I have a script that calls it, I get > > the following error: > > > > Bad free() ignored at <program name> line <x> This is a problem which I'm trying to track down. There are too many places where memory is allocated, and it is remarkably difficult to track down what's really being released improperly. It is almost certainly a conflict between DBD::Informix and ESQL/C. That makes it my problem. It seems to vary depending on how the Perl script is run -- I get different results running the same test in verbose and non-verbose modes. It seems to vary depending on the version of ESQL/C, too. There is a chunk of code in dbdimp.ec which is conditionally protected which frees blob space; it is not clear whether that needs beefing up or not. I hope to find a way of testing up front what needs to be done; it will complicate the process of building DBD::Informix for me, but simplify life for everyone else. The problem may be related to Perl's concept of mortality, as in mortal variables and immortal variables. > > where program name is the name of the script calling the > > function and x is the line number. This always occurs > > whenever I try to extract a blob from the database. The > > error occurs (according to the line number) on the line > > *immediately after* the function call even if the scalar is not > > used within that line. The scalar contains the blob as > > required but this error message is littering my web pages. > > I don't know whether this is a perl, DBI or Informix problem - > > can anyone help? > > According to Chapter 9 of the (second) camel book, this message means > "An internal routine called free(3) on something that had never been > malloc(3)ed in the first place" and describes it as "a severe warning > (mandatory). I've encountered this problem on a Solaris 2.6 machine > when I set variables in %ENV before making a call to system() so I > think it's actually a perl problem. > > >From the research I did when I found this problem, it seems to be a > bug on some platforms in perl5.004_04 as well as in perl5.005_02. > I've lost the references for this though, but there was some > discussion in the perl-porters mailing list. > > If you're feeling game, try using the following code to suppress the > warning: > > local $SIG{__WARN__} = sub { > print(STDERR @_) unless $_[0] =~ m/Bad free/; > }; Yours, Jonathan Leffler (jleffler@informix.com) #include <witticism.h> Guardian of DBD::Informix v0.60 -- http://www.perl.com/CPAN Informix IDN for D4GL & Linux -- http://www.informix.com/idn