 |
|
10-23-2007
|
#1 (permalink)
|
|
Resident Diabolist
Location: Geneva-Bern-Zürich, Switzerland;Oslo,Norway
|
Not Ranked
:
+0 / -0
0 score
abstract C++ question
How is the following possible?
1) I have a running program with the an option, say A, set to false; i.e.
2) I set
and get an error (it still runs but doesn't calculate because always out of bounds)
3) I set again
and get still the same error as after 2...
This is not clear at all to me because between every numbered step (i.e. 1 and 2 and 2 and 3) there is a make clean and then a make...so it shouldn't know anything from the preceeding right?
----------------
Administrator
A COUNTRY WITHOUT AN ARMY IS LIKE A FISH WITHOUT A BIKE!!!
I don't believe in god, but I do believe in what others call utopies.
|
|
10-23-2007
|
#2 (permalink)
|
|
Dedicated Smart-ass
Location: Just before 0xAA55
|
Not Ranked
:
+0 / -0
0 score
Re: abstract C++ question
it does not matter how many times you set a, as long as you are not accidentally redefining it (in which case you will get an error)
i can however see a possible problem with you using A in calculations, i would type cast it as int just to be on a safe side. i know posting the whole code may not be possible, but could you perhaps post more pieces that may give us a better picture of what may be happening?
----------------
Microsoft, the leader in using innovative tactics to promote irksome experience, coupled with antiquated technology that's held together by a pyramid of makeshift afterthoughts.
Apple, the leader in using irksome tactics to promote innovative experience, coupled with an antiquated core that's enhanced by state-of-the-art afterthoughts.
Linux, the leader in not using any tactics to promote user-defined experience, coupled with state-of-the-art core enhanced by innovative afterthoughts.

|
|
10-23-2007
|
#3 (permalink)
|
|
Resident Slayer
|
Not Ranked
:
+0 / -0
0 score
Re: abstract C++ question
This is the kind of bug for which a debugger is pretty much invaluable. Have you got one? You need to either have a break on change in value or step through the code starting where its "not the right value."
I had a developer not too long ago who thought he was such a hotshot that he could get by without using a debugger, just traces. He did not last long!
Step into,
Buffy
----------------
"If you do not agree with anything I say, I'll not only retract it, but deny under oath that I ever said it!"
__________________________________________________ ______________-- Tom Lehrer
"No Robbie, not Europe!"
Forum Administrator
Hypography Science Forums - Science for Boys and Girls! Its not for nothing that we hang out here.
|
|
10-23-2007
|
#4 (permalink)
|
|
Dedicated Smart-ass
Location: Just before 0xAA55
|
Not Ranked
:
+0 / -0
0 score
Re: abstract C++ question
mmmm, GDBlicious
----------------
Microsoft, the leader in using innovative tactics to promote irksome experience, coupled with antiquated technology that's held together by a pyramid of makeshift afterthoughts.
Apple, the leader in using irksome tactics to promote innovative experience, coupled with an antiquated core that's enhanced by state-of-the-art afterthoughts.
Linux, the leader in not using any tactics to promote user-defined experience, coupled with state-of-the-art core enhanced by innovative afterthoughts.

|
|
10-23-2007
|
#5 (permalink)
|
|
Explaining
Location: South East Queensland, Australia
|
Not Ranked
:
+0 / -0
0 score
Re: abstract C++ question
Quote:
Originally Posted by sanctus
This is not clear at all to me because between every numbered step (i.e. 1 and 2 and 2 and 3) there is a make clean and then a make...so it shouldn't know anything from the preceeding right?
|
Hi Sanctus,
It may be due to your 'A' being a restricted system variable name. Your documentation should provide a list of any restricted variable names.
|
|
10-24-2007
|
#6 (permalink)
|
|
Resident Diabolist
Location: Geneva-Bern-Zürich, Switzerland;Oslo,Norway
|
Not Ranked
:
+0 / -0
0 score
Re: abstract C++ question
Actually the code was not written by me, I just modified some parts (nothing though related to that). The code is too complicated to post it here giving a clue...'A' is just a name of an experience to use or not for computing the likelihood...
The problem with gdb is that I run this program on different (9) machines at university, so I don't really know how to use gdb. Additionally thing is that looking at the output on the different machines there isn't really an error of compilation but one written in the code (something like "in spline # x out of bounds") so it actually keeps turning but calculates nothing because out of bounds...but why in the beginning x was in bounds and then changing from false to true back to false it is out of bounds (as it was when it was true)?
----------------
Administrator
A COUNTRY WITHOUT AN ARMY IS LIKE A FISH WITHOUT A BIKE!!!
I don't believe in god, but I do believe in what others call utopies.
|
|
10-24-2007
|
#7 (permalink)
|
|
Resident Slayer
|
Not Ranked
:
+0 / -0
0 score
Re: abstract C++ question
Quote:
Originally Posted by sanctus
The problem with gdb is that I run this program on different (9) machines at university, so I don't really know how to use gdb.
|
Learn it on the one machine that has it installed! You'll be glad you did!
Why? Well...
Quote:
Originally Posted by sanctus
...there isn't really an error of compilation but one written in the code...
|
Debuggers are what you use when it compiles fine, but theres something in your algorithm that isn't working and you have to go in and watch what's going on in order to find where the flaw is.
But if you don't have the time to learn gdb (and really all you need to know is how to set a breakpoint and then inspect the variables that are making you miserable), then you need to "instrument" the app, which basically just means putting "writes" or "alerts" in your code at strategic places and see when x and a are changing. Put these in before and after every reference to them in the code that's not working.
Quite often when you have problems like you're describing, its either due to hidden side-effects (something is buried one level down in a function), or you've got scoping errors (x is a local variable that gets set in one place, goes out of scope and then gets recreated but now has no value).
If you were using C instead of C++, I'd also be looking for arrays that are going past their declared sizes and munging data in other variables that get allocated nearby on the heap, but you should be getting run-time errors for that (unless you were using an old generic unix "cc").
printf("It hasn't worked for the last %d loops.", i), 
Buffy
----------------
"If you do not agree with anything I say, I'll not only retract it, but deny under oath that I ever said it!"
__________________________________________________ ______________-- Tom Lehrer
"No Robbie, not Europe!"
Forum Administrator
Hypography Science Forums - Science for Boys and Girls! Its not for nothing that we hang out here.
|
|
10-24-2007
|
#8 (permalink)
|
|
Dedicated Smart-ass
Location: Just before 0xAA55
|
Not Ranked
:
+0 / -0
0 score
Re: abstract C++ question
g++ -ggdb -o prog prog.cpp
gdb prog
run

----------------
Microsoft, the leader in using innovative tactics to promote irksome experience, coupled with antiquated technology that's held together by a pyramid of makeshift afterthoughts.
Apple, the leader in using irksome tactics to promote innovative experience, coupled with an antiquated core that's enhanced by state-of-the-art afterthoughts.
Linux, the leader in not using any tactics to promote user-defined experience, coupled with state-of-the-art core enhanced by innovative afterthoughts.

|
|
10-25-2007
|
#9 (permalink)
|
|
Resident Diabolist
Location: Geneva-Bern-Zürich, Switzerland;Oslo,Norway
|
Not Ranked
:
+0 / -0
0 score
Re: abstract C++ question
I know the basics of gdb, so that is not the problem. The problem is that all machines are far away and on mine it takes about 1 hour to get to point where it starts calculating...so I can't try it on the machine that has it installed.
Alex to compile the program there is a makefile and I added the thing for gdb in the makefile:
Code:
FLAGS = -ggdb3 -Wall -DQT_THREAD_SUPPORT -DPRERELEASE $(WMAPDEFINE)
//ggdb3 added by me
It works fine when not running a montecarlo simulation since then I use my machine. I also tried the following:
when you are, via ssh, on the other machines you usually write
$ qsub -l nodes=9 -l walltime=500:00:00 ./mcrun
to use 9 machines that calculate for 500h. So I tried something like (it calculated so I did it the right way then)
$ gdb qsub -l nodes=9 -l walltime=500:00:00 ./mcrun
$ run
it calculated but since it does not give real errors only try-catch error written by the original coder gdb or not doesn't change much.
Now (I said I know a little gdb, but maybe I exarated) how do I set a breakpoint so that the program stops at a given point (i.e. when the catch error comes)?
----------------
Administrator
A COUNTRY WITHOUT AN ARMY IS LIKE A FISH WITHOUT A BIKE!!!
I don't believe in god, but I do believe in what others call utopies.
|
|
10-25-2007
|
#10 (permalink)
|
|
Resident Diabolist
Location: Geneva-Bern-Zürich, Switzerland;Oslo,Norway
|
Not Ranked
:
+0 / -0
0 score
Re: abstract C++ question
Now this is what I did:
Code:
$gdb mc_general
(gdb) break fastsplint()
Function "fastsplint()" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (fastsplint()) pending.
(gdb) exec qsub -l nodes=9 -l walltime=500:00:00 ./mcrun
(gdb) run
And then it starts and stops doing anything after:
Code:
Starting program: /usr/bin/qsub
Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0xffffe000
Any idea?
----------------
Administrator
A COUNTRY WITHOUT AN ARMY IS LIKE A FISH WITHOUT A BIKE!!!
I don't believe in god, but I do believe in what others call utopies.
|
|
 |
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
» Advertisement |
|
|
|