Class::DBI explodes on mod_perl/Win32 due to Cloneby fenLisesi (Priest)
|on Jan 31, 2008 at 14:04 UTC||Need Help??|
fenLisesi has asked for the
wisdom of the Perl Monks concerning the following question:
Greetings, wise ones -- humbled, as always, in your presence. I have come to seek your blessing on an apache remedy that I concocted.
In my attempts to get my Class::DBI webapp to graze on the plains of Redmond, I have found with grief that it reliably causes Apache2 to crash and burn whenever I try to run Apache2 with more threads than one, brought down by a swarm of flame-arrows, shot by the many threads. The typical dying words of the app include "Free to wrong pool" and "Attempt to free non-existent shared string", finger-written with its own blood, along with the address of Clone::clone in the Class::DBI source.
I replaced Clone::clone in Class/DBI.pm with Storable::dclone and there is no problem now, though a quick benchmark seems to indicate that the application has slowed down. Using the latest version of Clone or sundry versions of Apache2 had not helped. I believe all the perls that I tried had been built from ActiveState sources--I did not try Strawberry or other gcc-compiled perls.
As a fish out of water in Win32 land (though only a frog out of water elsewhere), I need to call upon Win32-experienced monks here. Is Clone inherently bad with multiple-threads of mod_perl2 on Win32, or could it be amenable to a fix by using this compiler instead of that, or downloading the whole combo from such and such repo etc?
How about Storable::dclone replacing Clone::clone? I have not had a chance to run extensive tests yet, but I hope I wasn't too optimistic when I assumed that the two were interchangeble.
Update: The relevant Apache directive is ThreadsPerChild. Having ThreadsPerChild N in httpd.conf with N greater than unity and stress-testing the app (slight stress, really) with apache ab or even by just quickly click-click-clicking for a few seconds on a link that leads to the Clone::clone line in Class/DBI.pm getting executed causes a crash. The webapp itself does not try to use threads.
Update: Class::DBI maintainers inform me that Storable::dclone and Clone::clone are not interchangable. As an example, they say that Storable::dclone cannot clone closures, which are created, for example, to implement triggers.