This makes the error stack traces unreadable because valgrind tries to resolve the symbol names after they were unloaded (and not when the error occurs).
});
}
+=head1 VARIABLES
+
+=head2 C<$dl_unload>
+
+When set to true, all dynamic extensions that were loaded during the analysis will be unloaded at C<END> time by L<DynaLoader::dl_unload_file>.
+
+Since this obfuscates error stack traces, it's disabled by default.
+
+=cut
+
+our $dl_unload;
+
END {
- if ($run and eval { require DynaLoader; 1 }) {
+ if ($dl_unload and $run and eval { require DynaLoader; 1 }) {
my @rest;
DynaLoader::dl_unload_file($_) or push @rest, $_ for @DynaLoader::dl_librefs;
@DynaLoader::dl_librefs = @rest;