Segmentation error on the same computer with Linux, but not with C ++ code

I have a particular problem. I developed C ++ - a program on a Linux cluster at work. I tried to use it on a Ubuntu 14.04 machine, but a program consisting of 6 files: main.hpp, main.cpp (depends on) sarsa.hpp, sarsa.cpp (Sarsa class) (depends on) wec.hpp, wec.cpp , compiles, but when I run it, it either returns segmenation faultor does not introduce one fundamental class function Sarsa.

The main code calls the constructor and setter functions without problems:

  Sarsa run;
  run.setVectorSize(memory,3,tilings,1000);

and etc.

However, it cannot run a public function episode, because learningRateit must contain a large integer and returns 0 for all episodes (iterations).

learningRate[episode]=run.episode(numSteps,graph);}

I tried debugging the code using gdb, which returned:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000408f4a in main () at main.cpp:152
152     learningRate[episode]=run.episode(numSteps,graph);}

valgrind, :

==10321==  Uninitialised value was created by a stack allocation
==10321==    at 0x408CAD: main (main.cpp:112)

.

, , sarsa.cpp, , , ,

++ v11 ( ), g++ -std=c++0x, .

, - . . ? , , ?

.

: main.cpp:

: `#define numEpisodes 10

int learningRate [numEpisodes]; `

main:

for (int episode; episode<numEpisodes; episode++) { if (episode==(numEpisodes-1)) { // Save the simulation data only at the graph=true;} // last episode learningRate[episode]=run.episode(numSteps,graph);}

+4
3

, , - , episode. , , - undefined, , - , .

+2

. , - , , , . , ; , , . , , .

learningRate[episode]. episode? learningRate?

+2

, , sarsa.cpp, , , ,

, main.cpp.

, , .

, , . , .

, , . Segfault - , . NULL. , . Valgrind , .

Without code, I cannot tell you why the pointer is not initialized when the program starts on your home system, but (apparently) is initialized when it starts at work. I suspect that you do not have the necessary data in your home system, but you need to research and understand this. The main question to ask yourself is "what is different from my dmy working computer on my home computer?"

0
source

All Articles