From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28092 invoked by alias); 10 Jul 2008 10:55:22 -0000 Received: (qmail 28082 invoked by uid 22791); 10 Jul 2008 10:55:22 -0000 X-Spam-Check-By: sourceware.org Received: from fg-out-1718.google.com (HELO fg-out-1718.google.com) (72.14.220.155) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 10 Jul 2008 10:55:02 +0000 Received: by fg-out-1718.google.com with SMTP id e21so1367397fga.28 for ; Thu, 10 Jul 2008 03:54:57 -0700 (PDT) Received: by 10.86.99.9 with SMTP id w9mr8597205fgb.70.1215687297058; Thu, 10 Jul 2008 03:54:57 -0700 (PDT) Received: by 10.86.66.18 with HTTP; Thu, 10 Jul 2008 03:54:57 -0700 (PDT) Message-ID: Date: Thu, 10 Jul 2008 10:58:00 -0000 From: "James Gregory" To: "Chris Jefferson" Subject: Re: Including affects whether or not program freezes? Cc: gcc-help@gcc.gnu.org In-Reply-To: <5cc6b04e0807090949g30d5aacckc170e6068093e5a4@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <5cc6b04e0807090949g30d5aacckc170e6068093e5a4@mail.gmail.com> X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-07/txt/msg00129.txt.bz2 On Wed, Jul 9, 2008 at 5:49 PM, Chris Jefferson wrote: >> 4. Compile with gcc 4.2.3 (Ubuntu 64 bit), with optimization: my >> program freezes in a particular function >> >> Debugging this is difficult. > > While I could well be repeating what others say, my usual tools for > situations like this, which (touch wood) tend to get me out of it: > > A) Turn on all warnings, and read what they say. I've found this kind > of thing can be caused by a missing return statement. No warnings... > B) Turn on the debugging standard library, if you are using any of the > STL in your code. OK this reported a problem somewhere else, but fixing it didn't make any difference to the freezing problem. > C) Find the minimial set of optimisation flags you need to trigger > your problem (in particular if you can turn off inlining it will make > things easier). This makes the next stage easier. At first it required -finline-functions, but then I manually inlined an a function called in the part which freezes and now the minimum set of flags that triggers the problem is: -O1 -fstrict-aliasing > D) Use valgrind and see what it comes up with. Nothing at all. A minimal version of the function which freezes is something like: bool AIInterpreter::is_group_like_this(int n_side, int n_group) { //it is the second condition (scanned_groups) which triggers this code branch, but deleting anything at all here removes the bug if ((!sides[n_side].groups[n_group].get_alive()) || !sides[my_side].scanned_groups[n_side][n_group] || sides[n_side].groups[n_group].get_in_hangar()) { while (l_iter != l_end) ++l_iter; return false; } write_log(L"it never gets this far"); } So I guess "while (l_iter != l_end)" is becoming an infinite loop, but if I log the value of &(*l_iter) and &(*l_end) on each loop then a) it removes the bug and b) there is nothing obviously wrong. Anything else I can do? James