Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • He discovered a very similiar thing with a while back. It's documented in a set of slides [] he did about exceptions...

    Basically, closures + exceptions are a bad thing. This needs to be documented better somewhere in Perl.


    • Exception::Class doesn't use closures and this problem is very different. The problem is that it stores Devel::StackTrace object in exceptions. And Devel::StackTrace references all arguments from all frames in stack trace. In this test case stack trace has a frame with call to test() sub which is passed $x variable so value of $x gets stored deeply somewhere in exception object.

      Ilya Martynov ( [])

  • by Matts (1087) on 2003.03.03 8:05 (#17655) Journal
      local $@;
      eval {
        my $x = Object->new();
      if ($@) {
    • Explicitly undefining $@ helps in my POE application but I can imaging a couple scenarious when it will not help. For example if you take my test case it still prints "21" instead of "12".

      Real fix is probably using weak refs to store args in stack trace or don't store store them at all. After all Exception::Class needs stack trace only to print error message for uncaught exceptions. It could just generate error message at the moment when exceptions is raised and do not store stack trace in exception objec


      Ilya Martynov ( [])

  • Exception::Class::Base->NoRefs(1);

    This will pass along the no_refs parameter to all Devel::StackTrace objects created, and no references will be stored.

    This should perhaps be the default, though.