On Mon, Jul 18, 2005 at 01:14:43AM -0400, Alex Vandiver wrote: > On Sun, 2005-07-10 at 14:29 +0100, Dave Mitchell wrote: > > I don't think this fix is robust. You save the current PV value of ERRSV, > > and then later set it back; in the meantime, ERRSV's PV may have been > > realloced, and message now points to free or realloced garbage. > Point. The attached patch uses save_item(ERRSV) to fully localize [EMAIL > PROTECTED] > Also added more tests that the previous patch didn't pass on. Thoughts? > - Alex
I like the idea of localising $@ before calling DESTROY, but unfortunately it breaks this test: lib/warnings..............................PROG: # pp_ctl.c use warnings 'misc' ; package Foo; DESTROY { die "@{$_[0]} foo bar" } { bless ['A'], 'Foo' for 1..10 } { bless ['B'], 'Foo' for 1..10 } EXPECTED: (in cleanup) A foo bar at - line 4. (in cleanup) B foo bar at - line 4. GOT: (in cleanup) A foo bar at - line 4. (in cleanup) A foo bar at - line 4. (in cleanup) A foo bar at - line 4. (in cleanup) A foo bar at - line 4. (in cleanup) A foo bar at - line 4. (in cleanup) A foo bar at - line 4. (in cleanup) A foo bar at - line 4. (in cleanup) A foo bar at - line 4. (in cleanup) A foo bar at - line 4. (in cleanup) A foo bar at - line 4. (in cleanup) B foo bar at - line 4. (in cleanup) B foo bar at - line 4. (in cleanup) B foo bar at - line 4. (in cleanup) B foo bar at - line 4. (in cleanup) B foo bar at - line 4. (in cleanup) B foo bar at - line 4. (in cleanup) B foo bar at - line 4. (in cleanup) B foo bar at - line 4. (in cleanup) B foo bar at - line 4. (in cleanup) B foo bar at - line 4. # Failed at ../lib/warnings.t line 186 The behaviour being tested here is that a die in a DESTROY gets converted to a warn with an (in cleanup) prefix, and that subsequent massages with the same suffix should be suppressed. The current supression mechanism relies on comparing the new message with the current value of ERRSV. I'm not really sure offhand of the best way round this. Perhaps have an extra PL_ var that holds the hash of the last (in cleanup) warning ??? -- My Dad used to say 'always fight fire with fire', which is probably why he got thrown out of the fire brigade.