On 11/18/2011 05:32 PM, Paul Howarth wrote:
On Fri, 18 Nov 2011 15:28:27 +0000
Andrew Haley<aph(a)redhat.com> wrote:
> On 11/18/2011 11:31 AM, Paul Howarth wrote:
>> One of my packages, pptp, suffers occasional segfaults as reported
>> in
http://bugzilla.redhat.com/749455. However, whilst investigating
>> this, it seems to be the case that simply rebuilding the package
>> using no optimization (-O0) as opposed to the default -O2 is enough
>> to stop this happening.
>>
>> This raises two questions (at least!):
>>
>> 1. Is it reasonable for me to flout the packaging guidelines by
>> rebuilding with -O0 until this is resolved?
>>
>> 2. How to determine what the actual problem is, e.g. a problem with
>> the way the code is written leading to unsafe optimizations, or a
>> gcc bug?
>
> You're just going to have to debug it.
>
> To start with, build with warnings, and look at them all. If none of
> that works and you're stuck, I'll have a look.
It already builds with -Wall and there are no warnings:
This doesn't mean
much.
Adding a couple of more agressive options, this is what happens to pptp:
orckit_quirks.c:65:2: warning: missing initializer
[-Wmissing-field-initializers]
orckit_quirks.c:65:2: warning: (near initialization for
'fixed_packet.header.pptp_type') [-Wmissing-field-initializers]
pptp.c:147:21: warning: unused parameter 'sig' [-Wunused-parameter]
pptp.c:153:19: warning: unused parameter 'sig' [-Wunused-parameter]
pptp.c:459:33: warning: dereferencing type-punned pointer might break
strict-aliasing rules [-Wstrict-aliasing]
pptp.c:492:65: warning: unused parameter 'argc' [-Wunused-parameter]
pptp_callmgr.c:105:48: warning: unused parameter 'envp' [-Wunused-parameter]
pptp_callmgr.c:202:48: warning: dereferencing type-punned pointer might
break strict-aliasing rules [-Wstrict-aliasing]
pptp_callmgr.c:215:17: warning: ignoring return value of 'read',
declared with attribute warn_unused_result [-Wunused-result]
pptp_callmgr.c:216:17: warning: ignoring return value of 'read',
declared with attribute warn_unused_result [-Wunused-result]
pptp_callmgr.c:325:29: warning: dereferencing type-punned pointer might
break strict-aliasing rules [-Wstrict-aliasing]
pptp_callmgr.c:330:28: warning: dereferencing type-punned pointer might
break strict-aliasing rules [-Wstrict-aliasing]
pptp_callmgr.c:358:25: warning: dereferencing type-punned pointer might
break strict-aliasing rules [-Wstrict-aliasing]
pptp_callmgr.c:368:44: warning: unused parameter 'inetaddr'
[-Wunused-parameter]
pptp_callmgr.c:39:29: warning: unused parameter 'sig' [-Wunused-parameter]
pptp_callmgr.c:44:29: warning: unused parameter 'sig' [-Wunused-parameter]
pptp_callmgr.c:71:18: warning: ignoring return value of 'write',
declared with attribute warn_unused_result [-Wunused-result]
pptp_ctrl.c:1062:13: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
pptp_ctrl.c:177:1: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
pptp_ctrl.c:206:31: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
pptp_ctrl.c:245:13: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
pptp_ctrl.c:535:14: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
pptp_gre.c:237:27: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
pptp_gre.c:241:30: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
pptp_gre.c:249:18: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
pptp_gre.c:260:23: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
pptp_gre.c:441:26: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
pptp_gre.c:446:23: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
pptp_gre.c:493:27: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
pptp_gre.c:527:19: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
pptp_gre.c:74:10: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
pptp_gre.c:85:19: warning: nested extern declaration of 'localbind'
[-Wnested-externs]
pptp_gre.c:92:29: warning: dereferencing type-punned pointer might break
strict-aliasing rules [-Wstrict-aliasing]
pptp_gre.c:99:28: warning: dereferencing type-punned pointer might break
strict-aliasing rules [-Wstrict-aliasing]
pptp_quirks.c:33:5: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
pptp_quirks.h:56:1: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
pqueue.c:220:11: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
pqueue.h:27:1: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
routing.c:117:8: warning: ignoring return value of 'fgets', declared
with attribute warn_unused_result [-Wunused-result]
routing.c:125:6: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
routing.c:155:6: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
routing.h:2:1: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
routing.h:3:1: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
test.c:145:14: warning: comparison between signed and unsigned integer
expressions [-Wsign-compare]
test.c:174:27: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
test.c:55:16: warning: comparison between signed and unsigned integer
expressions [-Wsign-compare]
test.c:99:14: warning: comparison between signed and unsigned integer
expressions [-Wsign-compare]
test.h:5:8: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
util.c:121:8: warning: ignoring return value of 'write', declared with
attribute warn_unused_result [-Wunused-result]
util.c:136:5: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
util.c:142:5: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
util.c:145:7: warning: ignoring return value of 'read', declared with
attribute warn_unused_result [-Wunused-result]
util.c:149:6: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
util.c:90:5: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
util.h:38:1: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
util.h:47:1: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
util.h:50:1: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
util.h:52:1: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
vector.c:38:9: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
vector.h:15:1: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
I can't spot anything obvious, but each of these are potential candiates
for issues and should be inspected.
> This is unlikely to be a gcc bug.
>
> Does the upstream package segfault?
Upstream's Makefile uses -O0 and doesn't appear to segfault (probably
as a result).
Does upstream have an explanation why they are doing so?
If being hostile, one would be tempted to consider this to be an attempt
to play down known issues of sloppy programming :-)
Ralf