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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
#!/usr/bin/env python
#
# Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
# David Mosberger <davidm@hpl.hp.com>
# Copyright 2010 Canonical Ltd.
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# Scan standard input for GCC warning messages that are likely to
# source of real 64-bit problems. In particular, see whether there
# are any implicitly declared functions whose return values are later
# interpreted as pointers. Those are almost guaranteed to cause
# crashes.
#
import re
import sys
implicit_pattern = re.compile(
"([^:]*):(\d+):(\d+:)? warning: implicit declaration "
"of function [`']([^']*)'")
pointer_pattern = re.compile(
"([^:]*):(\d+):(\d+:)? warning: "
+ "("
+ "(assignment"
+ "|initialization"
+ "|return"
+ "|passing arg \d+ of `[^']*'"
+ "|passing arg \d+ of pointer to function"
+ ") makes pointer from integer without a cast"
+ "|"
+ "cast to pointer from integer of different size)")
def main():
last_implicit_filename = ""
last_implicit_linenum = -1
last_implicit_func = ""
errlist = ""
in_line = False
warn_only = False
for arg in sys.argv[1:]:
if arg == '--inline':
in_line = True
elif arg == '--warnonly':
warn_only = True
rv = 0
while True:
line = sys.stdin.readline()
if in_line:
sys.stdout.write(line)
sys.stdout.flush()
if line == '':
break
m = implicit_pattern.match(line)
if m:
last_implicit_filename = m.group(1)
last_implicit_linenum = int(m.group(2))
last_implicit_func = m.group(4)
else:
m = pointer_pattern.match(line)
if m:
pointer_filename = m.group(1)
pointer_linenum = int(m.group(2))
if (last_implicit_filename == pointer_filename
and last_implicit_linenum == pointer_linenum):
err = "Function `%s' implicitly converted to pointer at " \
"%s:%d" % (last_implicit_func, last_implicit_filename,
last_implicit_linenum)
errlist += err+"\n"
print err
if not warn_only:
rv = 3
if len(errlist):
if in_line:
print errlist
print """
Our automated build log filter detected the problem(s) above that will
likely cause your package to segfault on architectures where the size of
a pointer is greater than the size of an integer, such as ia64 and amd64.
This is often due to a missing function prototype definition.
Since use of implicitly converted pointers is always fatal to the application
on ia64, they are errors. Please correct them for your next upload.
More information can be found at:
http://wiki.debian.org/ImplicitPointerConversions
"""
sys.exit(rv)
if __name__ == '__main__':
main()
|