public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "James Gregory" <james.jrg@gmail.com>
To: "Christoph Bartoschek" <bartoschek@gmx.de>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Including <iostream> affects whether or not program freezes?
Date: Tue, 05 Aug 2008 09:31:00 -0000	[thread overview]
Message-ID: <beb51c260808050230g327128d2ic1bfaf03dcd36a8a@mail.gmail.com> (raw)
In-Reply-To: <200808050845.44715.bartoschek@gmx.de>

On Tue, Aug 5, 2008 at 7:45 AM, Christoph Bartoschek <bartoschek@gmx.de> wrote:

>> 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?
>
> Did you find the bug? What was the problem?
>
> If you did not find it yet:
>
> 1. Check with a debugger that the while loop is indeed an endless loop.
> 2. You did not show what containers l_iter and l_end come from and what
> happens with the containers in this function.
>
> Christoph
>

I never did find the bug, no.

1. I thought gdb couldn't give accurate line numbers for optimized code?

In this slightly modified version of my code (I was attempting to cut
down the code as much as possible):

bool get_true() {
	return true;
}

bool AIInterpreter::is_group_like_this(int n_side, int n_group) {
	if ((!get_true())
	|| !sides[my_side].scanned_groups[n_side][n_group]
	|| !get_true()) {
		while (l_iter != l_end)
			++l_iter;
		return false;
	}
	write_log(L"it never gets this far");

gdb says:

Program received signal SIGINT, Interrupt.
0x0000000000404356 in AIInterpreter::is_group_like_this (this=0x659338,
    n_side=1, n_group=0) at src/AIInterpreter.cpp:388
388		if ((!get_true())
(gdb) bt
#0  0x0000000000404356 in AIInterpreter::is_group_like_this (this=0x659338,
    n_side=1, n_group=0) at src/AIInterpreter.cpp:388

I can't see how it could freeze on that line?

2. l_iter and l_end are of type std::basic_string<unsigned char>::const_iterator
As for what happens to the container, the full source code for the
cut-down version of the file is here:
http://rrgbis.svn.sourceforge.net/viewvc/rrgbis/rrgbis-bug/src/AIInterpreter.cpp?view=markup

And yes the code is a bit of a mess but hey I wrote that file years ago.

The "rrgbis-bug" directory is/was my attempt to find the minimal
amount of code required to make it freeze, though it's still almost
7000 lines of code in total, so I didn't really succeed.

I am no longer subscribed to gcc-help, so if anyone wants me to see a
reply please include me in the cc list.

Thanks,

James

  reply	other threads:[~2008-08-05  9:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-09  3:26 James Gregory
2008-07-09 12:03 ` Lionel B
2008-07-09 16:49   ` James Gregory
2008-07-09 18:08     ` Burlen Loring
2008-07-09 13:43 ` Andrew Bell
2008-07-09 14:35   ` Andrew Haley
2008-07-09 17:02 ` Chris Jefferson
2008-07-10 10:58   ` James Gregory
2008-08-05  6:45     ` Christoph Bartoschek
2008-08-05  9:31       ` James Gregory [this message]
2008-07-12 21:16   ` James Gregory
2008-07-12 21:05     ` James Gregory
2008-07-12 22:11     ` James Gregory

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=beb51c260808050230g327128d2ic1bfaf03dcd36a8a@mail.gmail.com \
    --to=james.jrg@gmail.com \
    --cc=bartoschek@gmx.de \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).