0

I have a C code OpenGL program that compiles and runs fine on my ubuntu machine. But when I compile and run it on another linux it causes a segmentation fault. I've used valgrind to see where the problem could be and here is a small portion of the output:

==21294== LEAK SUMMARY:
==21294==    definitely lost: 72 bytes in 1 blocks
==21294==    indirectly lost: 0 bytes in 0 blocks
==21294==      possibly lost: 0 bytes in 0 blocks
==21294==    still reachable: 191,932 bytes in 1,397 blocks
==21294==         suppressed: 0 bytes in 0 blocks
==21294== 
==21294== ERROR SUMMARY: 8 errors from 3 contexts (suppressed: 0 from 0)
==21294== 
==21294== 1 errors in context 1 of 3:
==21294== Syscall param ioctl(generic) points to uninitialised byte(s)
==21294==    at 0x5936F07: ioctl (syscall-template.S:84)
==21294==    by 0x7C0E0E7: drmIoctl (in /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0)
==21294==    by 0x7C10DDE: drmCommandWriteRead (in /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0)
==21294==    by 0xABF2DA0: nouveau_object_mthd (in /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2.0.0)
==21294==    by 0xABF3535: nouveau_device_new (in /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2.0.0)
==21294==    by 0xA0B9690: nouveau_drm_screen_create (in /usr/lib/x86_64-linux-gnu/dri/nouveau_dri.so)
==21294==    by 0x9C7FD15: ??? (in /usr/lib/x86_64-linux-gnu/dri/nouveau_dri.so)
==21294==    by 0x9F6C59B: ??? (in /usr/lib/x86_64-linux-gnu/dri/nouveau_dri.so)
==21294==    by 0x9F67BD2: ??? (in /usr/lib/x86_64-linux-gnu/dri/nouveau_dri.so)
==21294==    by 0x4E80AA2: ??? (in /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0)
==21294==    by 0x4E589C3: ??? (in /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0)
==21294==    by 0x4E53F00: glXQueryVersion (in /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0)

The full output file from valgrind is 15614 lines long. I'm still learning it but I could use assistance on reading what I'm looking at and how I can correct my code. Also this is my first post on this site, so any info for this question and posting in general would be appreciated.

ks1322
  • 33,961
  • 14
  • 109
  • 164
The_Fiz
  • 19
  • 1

1 Answers1

1

Segmentation fault has nothing to do with memory leaks. To fix segmentation fault you should read and fix errors reported by Valgrind, not memory leaks. According to output there are 8 errors found by Valgrind:

==21294== ERROR SUMMARY: 8 errors from 3 contexts (suppressed: 0 from 0)

See the difference between Valgrind errors and memory leaks here:
Error summary in Valgrind output?

ks1322
  • 33,961
  • 14
  • 109
  • 164