Re: Including <iostream> affects whether or not program freezes?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 5, 2008 at 7:45 AM, Christoph Bartoschek <bartoschek@xxxxxx> 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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux