Re: Package segfaults when built with -O2 but not with -O0
On 12/02/2011 02:08 PM, Paul Howarth wrote: On 12/02/2011 04:12 AM, Ralf Corsepius wrote: On 12/01/2011 07:11 PM, Paul Howarth wrote: On Thu, 01 Dec 2011 15:45:48 +0100 Ralf Corsepiusrc040...@freenet.de wrote: On 12/01/2011 11:23 AM, Paul Howarth wrote: Ralf, On 11/18/2011 05:53 PM, Ralf Corsepius wrote: On 11/18/2011 05:32 PM, Paul Howarth wrote: 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: What were the couple of more agressive options you used, This is what I did (rebased against today's git): diff --git a/pptp.spec b/pptp.spec index 289dd08..78e36ca 100644 --- a/pptp.spec +++ b/pptp.spec @@ -86,7 +86,7 @@ tunnels. perl -pi -e 's/install -o root -m 555 pptp/install -m 755 pptp/;' Makefile %build -make %{?_smp_mflags} CFLAGS=-Wall %{optflags} IP=/sbin/ip +make %{?_smp_mflags} CFLAGS=-Wall %{optflags} -Wextra -Wstrict-aliasing -Wnested-externs -Wstrict-prototypes IP=/sbin/ip %install rm -rf %{buildroot} and which distro? Local rawhide mock. The result I posted was extracted from a fedpkg mockbuild's build.log in a local mock on fedora-16/x86_64. I've tried -Wall -Wextra and still can't provoke the strict aliasing warning locally. -Wstrict-aliasing is responsible for this warning. Today's version looks like this: # grep warning: results_pptp/1.7.2/13.fc17/build.log | grep punned 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_callmgr.c:202:48: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] 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.c:459:33: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] This is weird: I can't reproduce these either locally in mock or in koji: Neither can I ;) http://koji.fedoraproject.org/koji/taskinfo?taskID=3555838 ... mock appends build.log's from subsequent mock runs ... ... the warnings above stem from older builds. I had not cleaned up the build.log when git merging your recent changes into my git checkout. Hmm, that sort of explains it - except that even if I don't apply any of the last few patches since the F14 version, I *still* can't provoke a strict-aliasing warning. Got it: I had to use -Wstrict-aliasing=2 Paul. -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
On 12/02/2011 04:12 AM, Ralf Corsepius wrote: On 12/01/2011 07:11 PM, Paul Howarth wrote: On Thu, 01 Dec 2011 15:45:48 +0100 Ralf Corsepiusrc040...@freenet.de wrote: On 12/01/2011 11:23 AM, Paul Howarth wrote: Ralf, On 11/18/2011 05:53 PM, Ralf Corsepius wrote: On 11/18/2011 05:32 PM, Paul Howarth wrote: 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: What were the couple of more agressive options you used, This is what I did (rebased against today's git): diff --git a/pptp.spec b/pptp.spec index 289dd08..78e36ca 100644 --- a/pptp.spec +++ b/pptp.spec @@ -86,7 +86,7 @@ tunnels. perl -pi -e 's/install -o root -m 555 pptp/install -m 755 pptp/;' Makefile %build -make %{?_smp_mflags} CFLAGS=-Wall %{optflags} IP=/sbin/ip +make %{?_smp_mflags} CFLAGS=-Wall %{optflags} -Wextra -Wstrict-aliasing -Wnested-externs -Wstrict-prototypes IP=/sbin/ip %install rm -rf %{buildroot} and which distro? Local rawhide mock. The result I posted was extracted from a fedpkg mockbuild's build.log in a local mock on fedora-16/x86_64. I've tried -Wall -Wextra and still can't provoke the strict aliasing warning locally. -Wstrict-aliasing is responsible for this warning. Today's version looks like this: # grep warning: results_pptp/1.7.2/13.fc17/build.log | grep punned 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_callmgr.c:202:48: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] 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.c:459:33: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] This is weird: I can't reproduce these either locally in mock or in koji: Neither can I ;) http://koji.fedoraproject.org/koji/taskinfo?taskID=3555838 ... mock appends build.log's from subsequent mock runs ... ... the warnings above stem from older builds. I had not cleaned up the build.log when git merging your recent changes into my git checkout. Hmm, that sort of explains it - except that even if I don't apply any of the last few patches since the F14 version, I *still* can't provoke a strict-aliasing warning. Paul. -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
Ralf, On 11/18/2011 05:53 PM, Ralf Corsepius wrote: On 11/18/2011 05:32 PM, Paul Howarth wrote: 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
Re: Package segfaults when built with -O2 but not with -O0
On 12/01/2011 11:23 AM, Paul Howarth wrote: Ralf, On 11/18/2011 05:53 PM, Ralf Corsepius wrote: On 11/18/2011 05:32 PM, Paul Howarth wrote: 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: What were the couple of more agressive options you used, This is what I did (rebased against today's git): diff --git a/pptp.spec b/pptp.spec index 289dd08..78e36ca 100644 --- a/pptp.spec +++ b/pptp.spec @@ -86,7 +86,7 @@ tunnels. perl -pi -e 's/install -o root -m 555 pptp/install -m 755 pptp/;' Makefile %build -make %{?_smp_mflags} CFLAGS=-Wall %{optflags} IP=/sbin/ip +make %{?_smp_mflags} CFLAGS=-Wall %{optflags} -Wextra -Wstrict-aliasing -Wnested-externs -Wstrict-prototypes IP=/sbin/ip %install rm -rf %{buildroot} and which distro? Local rawhide mock. The result I posted was extracted from a fedpkg mockbuild's build.log in a local mock on fedora-16/x86_64. I've tried -Wall -Wextra and still can't provoke the strict aliasing warning locally. -Wstrict-aliasing is responsible for this warning. Today's version looks like this: # grep warning: results_pptp/1.7.2/13.fc17/build.log | grep punned 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_callmgr.c:202:48: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] 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.c:459:33: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] Ralf -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
On Thu, 01 Dec 2011 15:45:48 +0100 Ralf Corsepius rc040...@freenet.de wrote: On 12/01/2011 11:23 AM, Paul Howarth wrote: Ralf, On 11/18/2011 05:53 PM, Ralf Corsepius wrote: On 11/18/2011 05:32 PM, Paul Howarth wrote: 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: What were the couple of more agressive options you used, This is what I did (rebased against today's git): diff --git a/pptp.spec b/pptp.spec index 289dd08..78e36ca 100644 --- a/pptp.spec +++ b/pptp.spec @@ -86,7 +86,7 @@ tunnels. perl -pi -e 's/install -o root -m 555 pptp/install -m 755 pptp/;' Makefile %build -make %{?_smp_mflags} CFLAGS=-Wall %{optflags} IP=/sbin/ip +make %{?_smp_mflags} CFLAGS=-Wall %{optflags} -Wextra -Wstrict-aliasing -Wnested-externs -Wstrict-prototypes IP=/sbin/ip %install rm -rf %{buildroot} and which distro? Local rawhide mock. The result I posted was extracted from a fedpkg mockbuild's build.log in a local mock on fedora-16/x86_64. I've tried -Wall -Wextra and still can't provoke the strict aliasing warning locally. -Wstrict-aliasing is responsible for this warning. Today's version looks like this: # grep warning: results_pptp/1.7.2/13.fc17/build.log | grep punned 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_callmgr.c:202:48: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] 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.c:459:33: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] This is weird: I can't reproduce these either locally in mock or in koji: http://koji.fedoraproject.org/koji/taskinfo?taskID=3555838 Paul. -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
Paul Howarth wrote: This is weird: I can't reproduce these either locally in mock or in koji: http://koji.fedoraproject.org/koji/taskinfo?taskID=3555838 -Wstrict-aliasing only works if -fstrict-aliasing is enabled, so if you're using -fno-strict-aliasing (or an optimization level below -O2 – -fstrict-aliasing is only enabled by default at -O2, -O3 or -Os), you won't get the warnings. -fno-strict-aliasing is a workaround for production builds, but it also sweeps the warnings under the carpet. Kevin Kofler -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
On 12/01/2011 07:11 PM, Paul Howarth wrote: On Thu, 01 Dec 2011 15:45:48 +0100 Ralf Corsepiusrc040...@freenet.de wrote: On 12/01/2011 11:23 AM, Paul Howarth wrote: Ralf, On 11/18/2011 05:53 PM, Ralf Corsepius wrote: On 11/18/2011 05:32 PM, Paul Howarth wrote: 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: What were the couple of more agressive options you used, This is what I did (rebased against today's git): diff --git a/pptp.spec b/pptp.spec index 289dd08..78e36ca 100644 --- a/pptp.spec +++ b/pptp.spec @@ -86,7 +86,7 @@ tunnels. perl -pi -e 's/install -o root -m 555 pptp/install -m 755 pptp/;' Makefile %build -make %{?_smp_mflags} CFLAGS=-Wall %{optflags} IP=/sbin/ip +make %{?_smp_mflags} CFLAGS=-Wall %{optflags} -Wextra -Wstrict-aliasing -Wnested-externs -Wstrict-prototypes IP=/sbin/ip %install rm -rf %{buildroot} and which distro? Local rawhide mock. The result I posted was extracted from a fedpkg mockbuild's build.log in a local mock on fedora-16/x86_64. I've tried -Wall -Wextra and still can't provoke the strict aliasing warning locally. -Wstrict-aliasing is responsible for this warning. Today's version looks like this: # grep warning: results_pptp/1.7.2/13.fc17/build.log | grep punned 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_callmgr.c:202:48: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] 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.c:459:33: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] This is weird: I can't reproduce these either locally in mock or in koji: Neither can I ;) http://koji.fedoraproject.org/koji/taskinfo?taskID=3555838 ... mock appends build.log's from subsequent mock runs ... ... the warnings above stem from older builds. I had not cleaned up the build.log when git merging your recent changes into my git checkout. Ralf -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
lör 2011-11-19 klockan 00:23 -0500 skrev Gregory Maxwell: This use to be more true, but there are multiple levels of -Wstrict-aliasing and I would be _highly_ surprised if the default gave a false alarm. I think you can reliably say that if you get a warning at the default level then you do have a language standards conformance problem, and that it actually changes the generated code... but maybe you don't actually crash on any particular system. A note here is that we do have packages crashing on ARM due to strict aliasing issues where the same code works fine on x86_64. presumablu due to differences in register usage. Regrads Henrik -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
On 11/18/2011 11:32 PM, Tom Lane wrote: Andrew Haley a...@redhat.com writes: On 11/18/2011 05:53 PM, Ralf Corsepius wrote: pptp.c:459:33: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] Bingo! Bugs like this must be fixed. Sometimes that's easier said than done. -fno-strict-aliasing might be your friend. It's always easier said than done! Still, one could argue that -fno-strict-aliasing is a fix, kinda sorta. My point is that you've got to do *something*; this warning must not be ignored. Andrew. -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
On 11/19/2011 01:23 PM, Andrew Haley wrote: On 11/18/2011 11:32 PM, Tom Lane wrote: Andrew Haleya...@redhat.com writes: On 11/18/2011 05:53 PM, Ralf Corsepius wrote: pptp.c:459:33: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] Bingo! Bugs like this must be fixed. Sometimes that's easier said than done. -fno-strict-aliasing might be your friend. It's always easier said than done! Still, one could argue that -fno-strict-aliasing is a fix, kinda sorta. It's a work-around to evaluate whether aliasing actucally is the cause of this BZ. My point is that you've got to do *something*; this warning must not be ignored. The code in question is a classic of the GCC-aliasing cases: sockaddr vs. sockaddr_{in,un,..} casts. The standard work-around to the GCC warnings would be using unions, containing fields of these types. Whether these spots actually are affected by aliasing issues, is a different matter. [I have seen cases of this sort, where aliasing actually had malicious effects, but I've also seen cases it didn't.] Ralf -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
On 11/19/2011 06:23 AM, Gregory Maxwell wrote: On Fri, Nov 18, 2011 at 11:27 PM, Ralf Corsepiusrc040...@freenet.de wrote: [1] -Wstrict-aliasing is one of these cases. The spots such warnings point to, often are broken, but not always, because GCC has difficulties in identifying these. This use to be more true, but there are multiple levels of -Wstrict-aliasing I know. and I would be _highly_ surprised if the default gave a false alarm. At least older gccs (IIRC, gcc-4.4.x) did fairly often. gcc-4.6.x is less agressively warning. If GCC is sure something is wrong, it is supposed to raise errors. This isn't true. E.g. you can write code which reads and uses uninitialized memory where the compiler is _absolutely sure_ of it. You still just get a warning. Well, ... this would qualify as a bug in GCC, IMHO. Ralf -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
Ralf Corsepius wrote: On 11/19/2011 06:23 AM, Gregory Maxwell wrote: On Fri, Nov 18, 2011 at 11:27 PM, Ralf Corsepiusrc040...@freenet.de wrote: If GCC is sure something is wrong, it is supposed to raise errors. This isn't true. E.g. you can write code which reads and uses uninitialized memory where the compiler is _absolutely sure_ of it. You still just get a warning. Well, ... this would qualify as a bug in GCC, IMHO. Unfortunately, that's what the standard requires. It requires the compiler to accept the code, but it allows it to compile it to anything, even to something deleting all your data. Kevin Kofler -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Package segfaults when built with -O2 but not with -O0
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? Paul. -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
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. This is unlikely to be a gcc bug. Does the upstream package segfault? Andrew. -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
On Fri, Nov 18, 2011 at 6:31 AM, Paul Howarth p...@city-fan.org wrote: 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? [Obviously Andrew's look at warnings advice is good but also…] See if you can reproduce it when compiled with -O2 -fno-strict-aliasing if not, then the package violates C rules for pointer aliasing and -Wstrict-aliasing=n can help you find the bug. Otherwise, reproduce the crash while running in valgrind and it's pretty likely that you'll see the cause there. (e.g. some use-uninitilized which turns out to be harmless in O0) Between these two that covers a pretty significant portion of bugs that vanish at O0. -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
On Fri, 18 Nov 2011 15:28:27 + Andrew Haley 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: http://koji.fedoraproject.org/koji/getfile?taskID=3507432name=build.log 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). Paul. -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
On Fri, 18 Nov 2011 16:32:23 + Paul Howarth p...@city-fan.org wrote: On Fri, 18 Nov 2011 15:28:27 + Andrew Haley 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. (clip) 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). Paul. .. but https://bugzilla.redhat.com/show_bug.cgi?id=749455 it's shown that the upstream makefile uses -Wall -O -Wuninitialized -g. According to the gcc man page, -O is equal to -O1. -- Jussi Lehtola Fedora Project Contributor jussileht...@fedoraproject.org -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
On 11/18/2011 05:32 PM, Paul Howarth wrote: On Fri, 18 Nov 2011 15:28:27 + Andrew Haleya...@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
Re: Package segfaults when built with -O2 but not with -O0
On Fri, 18 Nov 2011 18:43:30 +0200 Jussi Lehtola jussileht...@fedoraproject.org wrote: On Fri, 18 Nov 2011 16:32:23 + Paul Howarth p...@city-fan.org wrote: On Fri, 18 Nov 2011 15:28:27 + Andrew Haley 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. (clip) 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). Paul. .. but https://bugzilla.redhat.com/show_bug.cgi?id=749455 it's shown that the upstream makefile uses -Wall -O -Wuninitialized -g. According to the gcc man page, -O is equal to -O1. Ah, I could have sworn it explicitly said -O0. More importantly, the bug reporter now tells me that the -O0 build has now segfaulted - it just took longer to happen that way. So I'll go back to more conventional debugging now. Thanks anyway. Paul. -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
On Fri, 18 Nov 2011 18:53:03 +0100 Ralf Corsepius rc040...@freenet.de wrote: On 11/18/2011 05:32 PM, Paul Howarth wrote: On Fri, 18 Nov 2011 15:28:27 + Andrew Haleya...@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
Re: Package segfaults when built with -O2 but not with -O0
On 11/18/2011 05:53 PM, Ralf Corsepius wrote: pptp.c:459:33: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] Bingo! Bugs like this must be fixed. Andrew. -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
Andrew Haley a...@redhat.com writes: On 11/18/2011 05:53 PM, Ralf Corsepius wrote: pptp.c:459:33: warning: dereferencing type-punned pointer might break strict-aliasing rules [-Wstrict-aliasing] Bingo! Bugs like this must be fixed. Sometimes that's easier said than done. -fno-strict-aliasing might be your friend. -fwrapv is another good tool for keeping the compiler from breaking traditional understandings of C semantics. regards, tom lane -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
Paul Howarth wrote: Hmm, thanks for that. I naively assumed that -Wall was all warnings! I'll look into those. Indeed, -Wall is not really all. :-) -Wall -Wextra is closer to all, but there are still some things those won't warn about, e.g. -Wwrite-strings catches places which use a string literal as a potentially writable char * instead of a const char *. Kevin Kofler -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
Kevin Kofler wrote: Indeed, -Wall is not really all. :-) -Wall -Wextra is closer to all, but there are still some things those won't warn about, e.g. -Wwrite-strings catches places which use a string literal as a potentially writable char * instead of a const char *. -O2 is required by -Warray-bounds. ALL C code should be compiled with -O2 -Wall -W(aka -Wextra). And _maybe_ also with -std= and -pedantic, + splint + valgrind ... see: http://gcc.gnu.org/onlinedocs/gcc-4.6.2/gcc/Warning-Options.html -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
On 11/19/2011 04:57 AM, Xose Vazquez Perez wrote: Kevin Kofler wrote: Indeed, -Wall is not really all. :-) -Wall -Wextra is closer to all, but there are still some things those won't warn about, e.g. -Wwrite-strings catches places which use a string literal as a potentially writable char * instead of a const char *. -O2 is required by -Warray-bounds. ALL C code should be compiled with -O2 -Wall -W(aka -Wextra). And _maybe_ also with -std= and -pedantic, + splint + valgrind ... ... you'd get lost, because many of the warnings - aggressive -W flags trigger are false/bogus [1] - aggressive -W flags trigger are GCC stylishness and are no real bugs. - -std=... is not helpful for bug-chasing. Keep in mind, warnings are _hints_ ... they point at spots into the code, GCC believes something could be wrong, but they do not necessarily means something actually is wrong. If GCC is sure something is wrong, it is supposed to raise errors. Ralf [1] -Wstrict-aliasing is one of these cases. The spots such warnings point to, often are broken, but not always, because GCC has difficulties in identifying these. -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
Re: Package segfaults when built with -O2 but not with -O0
On Fri, Nov 18, 2011 at 11:27 PM, Ralf Corsepius rc040...@freenet.de wrote: [1] -Wstrict-aliasing is one of these cases. The spots such warnings point to, often are broken, but not always, because GCC has difficulties in identifying these. This use to be more true, but there are multiple levels of -Wstrict-aliasing and I would be _highly_ surprised if the default gave a false alarm. I think you can reliably say that if you get a warning at the default level then you do have a language standards conformance problem, and that it actually changes the generated code... but maybe you don't actually crash on any particular system. I don't think 'the code is objectively wrong in a meaningful way' is a false alarm. I've seen code that miscompiled and crashed due to violating the aliasing rules but only threw a warning at higher levels. It's arguably too conservative already. If GCC is sure something is wrong, it is supposed to raise errors. This isn't true. E.g. you can write code which reads and uses uninitialized memory where the compiler is _absolutely sure_ of it. You still just get a warning. The compiler would be compatible with the spec if it replaced this program with system(rm -rf /), but you only get a warning. I quote the manual: Errors report problems that make it impossible to compile your program. (Though I agree with your view wrt the unfortunateness of style-warnings (omg you used a ^ without fifty parentheses) being hard to separate from ones where the compiler knows that your code is broken.) -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel