This answer is to dorbie:
Instead of “etc. etc.” tell us what the rest of the stack looks like, the important part that’ll tell where in your app the error occurred.
Ok, in that case: I’ll tell where I think the problem is, and then copy paste the rest instead of the “etc. etc”:
It seems like the program crashes before making use of any glut-stuff, namely I’m positive that: It never constructs gearClassFile::gearClassFile in main.cpp, line 257-268 so I never get below main.cpp line 270++. The class gearClassFile has a constructor, line 188, in gearClass.cpp. The last thing the constructor does, is this:
callFortranFile(); // line 229 of gearClass.cpp
cout << "Leaving constructor of: gearClassFile::gearClassFile..." << endl;
cout << endl; // line 231 of gearClass.cpp
}
I know that callFortranFile is called (line 229), but line 230+231 is never executed above. So let’s step further down into it:
void gearClassFile::callFortranFile() // line 270 of gearClass.cpp
{
makeLineSep(); // line 272 of gearClass.cpp
cout << "Writing text file for Fortran tooth profiler..." << endl;
This is executed, ok… Let’s look at the end of this member function:
saveBezier(N_kontur, &cpp_Kontur_id[0],
&cpp_X[0], &cpp_Y[0],
&dataPosX[0], &dataNegX[0]);
cout << "Done saveBezier, leaving gearClassFile::callFortranFile()..." << endl;
} // this is line 339 in gearClass.cpp
All of this is executed, which must mean that callFortranFile succeeded - at least it couts the last cout before the “}”… Hmm. So, what now? What should I test?
Based on this, I would say that the program should jump back to the constructor
gearClassFile::gearClassFile (lines 188 - 232, namely the to point where it left, i.e is should now go to line 230+231). But it crashes… Why? I think maybe I have some invalid pointer, but to me, it doesnt make sense that it crashes here… I don’t see any reason to crash here… Probably has to do with my virtual/polymorphism, as this is my first time, trying to do something like this (gearClassFile inherits from “drawableObj”, which is found in helper.cpp/helper.h).
I’m totally lost…
Here’s the “etc. etc”-part, you asked about - (I don’t understand it):
Done saveBezier, leaving gearClassFile::callFortranFile()...
*** glibc detected *** ./gears: munmap_chunk(): invalid pointer: 0x000000000064a5e0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x78a96)[0x7f29a6137a96]
/lib/x86_64-linux-gnu/libc.so.6(fclose+0x155)[0x7f29a6127715]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZNSt12__basic_fileIcE5closeEv+0x30)[0x7f29a696dbc0]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZNSt13basic_filebufIcSt11char_traitsIcEE5closeEv+0xa1)[0x7f29a6971411]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev+0x3d)[0x7f29a69719fd]
./gears[0x405a4b]
./gears[0x404fd9]
./gears[0x409d5e]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7f29a60e030d]
./gears[0x402499]
======= Memory map: ========
00400000-0040e000 r-xp 00000000 00:16 3563531 /home/mfjo/Downloads/gear_test/gears
0060d000-0060e000 r--p 0000d000 00:16 3563531 /home/mfjo/Downloads/gear_test/gears
0060e000-0060f000 rw-p 0000e000 00:16 3563531 /home/mfjo/Downloads/gear_test/gears
00641000-0068d000 rw-p 00000000 00:00 0 [heap]
7f29a2ed7000-7f29a2edc000 r-xp 00000000 08:05 4462103 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7f29a2edc000-7f29a30db000 ---p 00005000 08:05 4462103 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7f29a30db000-7f29a30dc000 r--p 00004000 08:05 4462103 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7f29a30dc000-7f29a30dd000 rw-p 00005000 08:05 4462103 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7f29a30dd000-7f29a30df000 r-xp 00000000 08:05 4456672 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7f29a30df000-7f29a32de000 ---p 00002000 08:05 4456672 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7f29a32de000-7f29a32df000 r--p 00001000 08:05 4456672 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7f29a32df000-7f29a32e0000 rw-p 00002000 08:05 4456672 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7f29a32e0000-7f29a32fb000 r-xp 00000000 08:05 4464316 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7f29a32fb000-7f29a34fa000 ---p 0001b000 08:05 4464316 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7f29a34fa000-7f29a34fb000 r--p 0001a000 08:05 4464316 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7f29a34fb000-7f29a34fc000 rw-p 0001b000 08:05 4464316 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7f29a34fc000-7f29a34fe000 r-xp 00000000 08:05 153333 /lib/x86_64-linux-gnu/libdl-2.13.so
7f29a34fe000-7f29a36fe000 ---p 00002000 08:05 153333 /lib/x86_64-linux-gnu/libdl-2.13.so
7f29a36fe000-7f29a36ff000 r--p 00002000 08:05 153333 /lib/x86_64-linux-gnu/libdl-2.13.so
7f29a36ff000-7f29a3700000 rw-p 00003000 08:05 153333 /lib/x86_64-linux-gnu/libdl-2.13.so
7f29a3700000-7f29a3707000 r-xp 00000000 08:05 131096 /lib/x86_64-linux-gnu/librt-2.13.so
7f29a3707000-7f29a3906000 ---p 00007000 08:05 131096 /lib/x86_64-linux-gnu/librt-2.13.so
7f29a3906000-7f29a3907000 r--p 00006000 08:05 131096 /lib/x86_64-linux-gnu/librt-2.13.so
7f29a3907000-7f29a3908000 rw-p 00007000 08:05 131096 /lib/x86_64-linux-gnu/librt-2.13.so
7f29a3908000-7f29a391a000 r-xp 00000000 08:05 4464434 /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7f29a391a000-7f29a3b19000 ---p 00012000 08:05 4464434 /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7f29a3b19000-7f29a3b1a000 r--p 00011000 08:05 4464434 /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7f29a3b1a000-7f29a3b1b000 rw-p 00012000 08:05 4464434 /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7f29a3b1b000-7f29a3c4e000 r-xp 00000000 08:05 4464332 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
7f29a3c4e000-7f29a3e4e000 ---p 00133000 08:05 4464332 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
7f29a3e4e000-7f29a3e4f000 r--p 00133000 08:05 4464332 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
7f29a3e4f000-7f29a3e53000 rw-p 00134000 08:05 4464332 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
7f29a3e53000-7f29a5447000 r-xp 00000000 08:05 4589398 /usr/lib/nvidia-current-updates/libnvidia-glcore.so.280.13
7f29a5447000-7f29a5646000 ---p 015f4000 08:05 4589398 /usr/lib/nvidia-current-updates/libnvidia-glcore.so.280.13
7f29a5646000-7f29a5c85000 rwxp 015f3000 08:05 4589398 /usr/lib/nvidia-current-updates/libnvidia-glcore.so.280.13
7f29a5c85000-7f29a5c9f000 rwxp 00000000 00:00 0
7f29a5c9f000-7f29a5ca2000 r-xp 00000000 08:05 4590577 /usr/lib/nvidia-current-updates/tls/libnvidia-tls.so.280.13
7f29a5ca2000-7f29a5ea1000 ---p 00003000 08:05 4590577 /usr/lib/nvidia-current-updates/tls/libnvidia-tls.so.280.13
7f29a5ea1000-7f29a5ea2000 rw-p 00002000 08:05 4590577 /usr/lib/nvidia-current-updates/tls/libnvidia-tls.so.280.13
7f29a5ea2000-7f29a5eba000 r-xp 00000000 08:05 153340 /lib/x86_64-linux-gnu/libpthread-2.13.so
7f29a5eba000-7f29a60b9000 ---p 00018000 08:05 153340 /lib/x86_64-linux-gnu/libpthread-2.13.so
7f29a60b9000-7f29a60ba000 r--p 00017000 08:05 153340 /lib/x86_64-linux-gnu/libpthread-2.13.so
7f29a60ba000-7f29a60bb000 rw-p 00018000 08:05 153340 /lib/x86_64-linux-gnu/libpthread-2.13.so
7f29a60bb000-7f29a60bf000 rw-p 00000000 00:00 0
7f29a60bf000-7f29a6254000 r-xp 00000000 08:05 153332 /lib/x86_64-linux-gnu/libc-2.13.so
7f29a6254000-7f29a6453000 ---p 00195000 08:05 153332 /lib/x86_64-linux-gnu/libc-2.13.so
7f29a6453000-7f29a6457000 r--p 00194000 08:05 153332 /lib/x86_64-linux-gnu/libc-2.13.so
7f29a6457000-7f29a6458000 rw-p 00198000 08:05 153332 /lib/x86_64-linux-gnu/libc-2.13.so
7f29a6458000-7f29a645e000 rw-p 00000000 00:00 0
7f29a645e000-7f29a6473000 r-xp 00000000 08:05 139316 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f29a6473000-7f29a6672000 ---p 00015000 08:05 139316 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f29a6672000-7f29a6673000 r--p 00014000 08:05 139316 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f29a6673000-7f29a6674000 rw-p 00015000 08:05 139316 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f29a6674000-7f29a66f7000 r-xp 00000000 08:05 153342 /lib/x86_64-linux-gnu/libm-2.13.so
7f29a66f7000-7f29a68f6000 ---p 00083000 08:05 153342 /lib/x86_64-linux-gnu/libm-2.13.so
7f29a68f6000-7f29a68f7000 r--p 00082000 08:05 153342 /lib/x86_64-linux-gnu/libm-2.13.so
7f29a68f7000-7f29a68f8000 rw-p 00083000 08:05 153342 /lib/x86_64-linux-gnu/libm-2.13.so
7f29a68f8000-7f29a69e0000 r-xp 00000000 08:05 4459448 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7f29a69e0000-7f29a6be0000 ---p 000e8000 08:05 4459448 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7f29a6be0000-7f29a6be8000 r--p 000e8000 08:05 4459448 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7f29a6be8000-7f29a6bea000 rw-p 000f0000 08:05 4459448 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7f29a6bea000-7f29a6bff000 rw-p 00000000 00:00 0
7f29a6bff000-7f29a6c6a000 r-xp 00000000 08:05 4465298 /usr/lib/x86_64-linux-gnu/libGLU.so.1.3.071100
7f29a6c6a000-7f29a6e69000 ---p 0006b000 08:05 4465298 /usr/lib/x86_64-linux-gnu/libGLU.so.1.3.071100
7f29a6e69000-7f29a6e6b000 r--p 0006a000 08:05 4465298 /usr/lib/x86_64-linux-gnu/libGLU.so.1.3.071100
7f29a6e6b000-7f29a6e6c000 rw-p 0006c000 08:05 4465298 /usr/lib/x86_64-linux-gnu/libGLU.so.1.3.071100
7f29a6e6c000-7f29a6eaa000 r-xp 00000000 08:05 4470684 /usr/lib/libglut.so.3.9.0
7f29a6eaa000-7f29a70a9000 ---p 0003e000 08:05 4470684 /usr/lib/libglut.so.3.9.0
7f29a70a9000-7f29a70ad000 r--p 0003d000 08:05 4470684 /usr/lib/libglut.so.3.9.0
7f29a70ad000-7f29a70b2000 rw-p 00041000 08:05 4470684 /usr/lib/libglut.so.3.9.0
7f29a70b2000-7f29a7173000 r-xp 00000000 08:05 4590222 /usr/lib/nvidia-current-updates/libGL.so.280.13
7f29a7173000-7f29a7372000 ---p 000c1000 08:05 4590222 /usr/lib/nvidia-current-updates/libGL.so.280.13
7f29a7372000-7f29a73ad000 rwxp 000c0000 08:05 4590222 /usr/lib/nvidia-current-updates/libGL.so.280.13
7f29a73ad000-7f29a73c3000 rwxp 00000000 00:00 0
7f29a73c3000-7f29a73d2000 r-xp 00000000 08:05 153339 /lib/x86_64-linux-gnu/ld-2.13.so
7f29a73d2000-7f29a73d3000 -wxp 0000f000 08:05 153339 /lib/x86_64-linux-gnu/ld-2.13.so
7f29a73d3000-7f29a73e4000 r-xp 00010000 08:05 153339 /lib/x86_64-linux-gnu/ld-2.13.so
7f29a755b000-7f29a75aa000 rw-p 00000000 00:00 0
7f29a75e1000-7f29a75e3000 rw-p 00000000 00:00 0
7f29a75e3000-7f29a75e4000 r--p 00020000 08:05 153339 /lib/x86_64-linux-gnu/ld-2.13.so
7f29a75e4000-7f29a75e6000 rw-p 00021000 08:05 153339 /lib/x86_64-linux-gnu/ld-2.13.so
7ffffae02000-7ffffae23000 rw-p 00000000 00:00 0 [stack]
7ffffafe9000-7ffffafea000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted
Looks like there’s something wrong when closing your file, but perhaps it was closed as a result of an error.
Make sure the file opened correctly.
I don’t think this is a problem. It seems to write (Verzahnen.txt) + read correctly from the file (Kontur.dat) and in any case, if it failed with file I/O, I wouldn’t expect such a crash with the message: “*** glibc detected *** ./gears: munmap_chunk(): invalid pointer: 0x000000000064a5e0 ***”. I don’t understand this message “glibc detected… etc.”
Invalid pointer: Probably correct, but I don’t know where (or how to fix)…
This is probably not an OpenGL question but more of a general programming question.
Yes, but if I asked in a general programming forum, people would complain about the use of glut-functions in my code and then they would say I should ask in an openGL forum. Another reason for me to ask here, is that the reason for me to (try to use) polymorphism, is that I want a single global class/place from where I can do this:
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
//==================
glPushMatrix();
glTranslatef(xPos, yPos, 0.0);
for (int z=0; z<(int) allObjs.pObjs.size(); z++)
{
glPushMatrix();
(allObjs.pObjs[z])->updateDisplay(); // <=== NB!!! NICE!
glPopMatrix();
}
....
.... // etc
}
You should perhaps know that in top of my main.cpp, line 14, I have this:
drawableObj allObjs; // must be global! - defined in helper.cpp/helper.h
And the problem I have with my gearClassFile::gearClassFile (constructor, never succeeds) inherits from drawableObj, and I would never do this if it wasn’t for openGL. I save a pointer to my graphics objects into allObjs.pObjs[0] (global) so I have a single place, where I can update my display in my openGL-loop…
So I belive - although there is some “general programming problem” here, it is highly worth asking about advice for it, in an openGL-forum.
I’m sorry if I haven’t explained it good enough… I’ll read followup answers/questions and try to elaborate, my poor explanation… Bottom line is: This crash is really strange, in my mind and I don’t understand why it crashes exactly where it does…