summaryrefslogtreecommitdiff
path: root/Porting/thirdclean
blob: 86103f77face186a46f20dd0b091801c29a76fe2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
local $/;
$_ = <ARGV>;

my @accv = /(^-+ \w+ -- \d+ --(?:.(?!^-))+)/msg;
my @leak = /(\d+ bytes? in \d+ leaks? .+? created at:(?:.(?!^[\d-]))+)/msg;

$leak[ 0] =~ s/.* were found:\n\n//m; # Snip off totals.

# Weed out the known access violations.

@accv = grep { ! /-- ru[hs] --.+setlocale.+Perl_init_i18nl10n/s }  @accv;
@accv = grep { ! /-- [rw][ui]s --.+_doprnt_dis/s }                 @accv;
@accv = grep { ! /-- (?:fon|ris) --.+__strxfrm/s }                 @accv;
@accv = grep { ! /-- rus --.+__catgets/s }                         @accv;
@accv = grep { ! /-- rus --.+__execvp/s }                          @accv;
@accv = grep { ! /-- rus --.+tmpnam.+tmpfile/s }                   @accv;
@accv = grep { ! /-- rus --.+__gethostbyname/s }                   @accv;
@accv = grep { ! /-- ris --.+__actual_atof/s }                     @accv;
@accv = grep { ! /-- ris --.+__strftime/s }                        @accv;

# Weed out untraceable access violations.
@accv = grep { ! / ----- /s }                                      @accv;
@accv = grep { ! /-- r[ui][hs] --.+proc_at_/s }                    @accv;
@accv = grep { ! /-- r[ui][hs] --.+pc = 0x/s }                     @accv;

# The following look like being caused by the intrinsic inlined
# string handling functions reading one or few bytes beyond the
# actual length.
@accv = grep { ! /-- rih --.+(?:memmove|strcpy).+moreswitches/s }  @accv;
@accv = grep { ! /-- (?:rih|rus) --.+strcpy.+gv_fetchfile/s }      @accv;
@accv = grep { ! /-- rih --.+strcmp.+doopen_pm/s }                 @accv;
@accv = grep { ! /-- rih --.+strcmp.+gv_fetchpv/s }                @accv;
@accv = grep { ! /-- r[ui]h --.+strcmp.+gv_fetchmeth/s }           @accv;
@accv = grep { ! /-- rih --.+memmove.+my_setenv/s }                @accv;
@accv = grep { ! /-- rih --.+memmove.+catpvn_flags/s }             @accv;

# yyparse.
@accv = grep { ! /Perl_yyparse/s }                                 @accv;

# Weed out the known memory leaks.

@leak = grep { ! /setlocale.+Perl_init_i18nl10n/s }   @leak;
@leak = grep { ! /setlocale.+set_numeric_standard/s } @leak;
@leak = grep { ! /_findiop.+fopen/s }                 @leak;
@leak = grep { ! /_findiop.+__fdopen/s }              @leak;
@leak = grep { ! /__localtime/s }                     @leak;
@leak = grep { ! /__get_libc_context/s }              @leak;
@leak = grep { ! /__sia_init/s }                      @leak;

# Weed out untraceable memory leaks.
@leak = grep { ! / ----- /s }                         @leak;
@leak = grep { ! /pc = 0x/s }                         @leak;
@leak = grep { ! /_pc_range_table/s }                 @leak;
@leak = grep { ! /_add_gp_range/s }                   @leak;

# yyparse.
@leak = grep { ! /Perl_yyparse/s }                    @leak;

# Output the cleaned up report.

# Access violations.

for (my $i = 0; $i < @accv; $i++) {
  $_ = $accv[$i];
  s/\d+/$i/;
  print;
}

# Memory leaks.

my ($leakb, $leakn, $leaks);

for (my $i = 0; $i < @leak; $i++) {
  $_ = $leak[$i];
  print $_, "\n";
  /^(\d+) bytes? in (\d+) leak/;
  $leakb += $1;
  $leakn += $2;
  $leaks += $1 if /including (\d+) super/;
}

print "Bytes $leakb Leaks $leakn Super $leaks\n" if $leakb;