Simple OpenGL demo crashes

I was trying to use some OpenGL software on the vim3 and encountered segmentation fault all the time.

I only have very basic knowledge to OpenGL and no experience with OpenGL ES, but I tried to gather some information on this issue.

Here is minimal reproducible example:

  1. try tutorial 2 in this repo
    https://github.com/tharkum/opengl-demo
  2. make and run the binary, got a dot in the window, great.
  3. In main.cpp, change
    GraphicsTimer* timer = new GraphicsTimer(500, render_cb, &context); to
    GraphicsTimer* timer = new GraphicsTimer(30, render_cb, &context); or anything lower than 200.
  4. make and run. Boom, segmentation fault.

I was stunned because I can’t even get a dot displayed at 30fps.

My log shows:

khadas@Khadas:~/Downloads/opengl-demo/tutorial02$ gdb -ex run --args ./tutorial02
Reading symbols from ./tutorial02...(no debugging symbols found)...done.
Starting program: /home/khadas/Downloads/opengl-demo/tutorial02/tutorial02
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fb31921d0 (LWP 5665)]
[New Thread 0x7faa9911d0 (LWP 5666)]
[New Thread 0x7fb29911d0 (LWP 5667)]
[New Thread 0x7fb21901d0 (LWP 5668)]
[New Thread 0x7fb198f1d0 (LWP 5669)]
[New Thread 0x7fb118e1d0 (LWP 5670)]
[New Thread 0x7fb06b5910 (LWP 5671)]
[New Thread 0x7fabfff1d0 (LWP 5672)]
[New Thread 0x7fab7fe1d0 (LWP 5673)]
[New Thread 0x7faa1901d0 (LWP 5674)]
[New Thread 0x7fa998f1d0 (LWP 5675)]
[New Thread 0x7fa918e1d0 (LWP 5676)]
[New Thread 0x7fa898d1d0 (LWP 5677)]
[New Thread 0x7f7bfff1d0 (LWP 5678)]
[New Thread 0x7f7b7fe1d0 (LWP 5679)]
[New Thread 0x7f7affd1d0 (LWP 5680)]
[New Thread 0x7f7a7fc1d0 (LWP 5681)]
[New Thread 0x7f79ffb1d0 (LWP 5682)]
[New Thread 0x7f797fa1d0 (LWP 5683)]
[New Thread 0x7f78ff91d0 (LWP 5684)]
[New Thread 0x7f57fff1d0 (LWP 5685)]

Thread 9 "tutorial02" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fabfff1d0 (LWP 5672)]
0x0000007fb3d3687c in llvm::Value::getName() const ()
   from /usr/lib/aarch64-linux-gnu/libLLVM-8.so.1
(gdb) bt
#0  0x0000007fb3d3687c in llvm::Value::getName() const ()
   from /usr/lib/aarch64-linux-gnu/libLLVM-8.so.1
#1  0x0000007fb3cf9a14 in llvm::FPPassManager::runOnFunction(llvm::Function&)
    () from /usr/lib/aarch64-linux-gnu/libLLVM-8.so.1
#2  0x0000007fb3cf9c2c in llvm::FPPassManager::runOnModule(llvm::Module&) ()
   from /usr/lib/aarch64-linux-gnu/libLLVM-8.so.1
#3  0x0000007fb3cf9f98 in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()
   from /usr/lib/aarch64-linux-gnu/libLLVM-8.so.1
#4  0x0000007fb4abc488 in llvm::MCJIT::emitObject(llvm::Module*) ()
   from /usr/lib/aarch64-linux-gnu/libLLVM-8.so.1
#5  0x0000007fb4abc858 in llvm::MCJIT::generateCodeForModule(llvm::Module*) ()
   from /usr/lib/aarch64-linux-gnu/libLLVM-8.so.1
#6  0x0000007fb4abd058 in llvm::MCJIT::finalizeObject() ()
   from /usr/lib/aarch64-linux-gnu/libLLVM-8.so.1
#7  0x0000007fb4a9ed58 in LLVMGetPointerToGlobal ()
   from /usr/lib/aarch64-linux-gnu/libLLVM-8.so.1
#8  0x0000007fb692d23c in ?? ()
   from /usr/lib/aarch64-linux-gnu/dri/swrast_dri.so
#9  0x0000007fb7365000 in ?? ()
   from /usr/lib/aarch64-linux-gnu/dri/swrast_dri.so
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)

I am wondering if this is a GPU driver issue.

More background:
The software I planned to run was Kstars, a planetarium software that renders the stars in the sky. It crashed every time at startup. Logs below.
A similar software, carte du ciel (sky chart) can run OK using its armhf package. The aarch64
version can be opened but if I drag the chart, it crashes with the same error.

    khadas@Khadas:~$ gdb -ex run --args kstars
    Reading symbols from kstars...(no debugging symbols found)...done.
    Starting program: /usr/bin/kstars
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
    [New Thread 0x7faec51090 (LWP 8651)]
    [New Thread 0x7fae3e7090 (LWP 8653)]
    [New Thread 0x7fadbe6090 (LWP 8654)]
    [New Thread 0x7fad3e5090 (LWP 8655)]
    [New Thread 0x7facbe4090 (LWP 8656)]
    [New Thread 0x7fa7fff090 (LWP 8657)]
    [New Thread 0x7fa77fe090 (LWP 8658)]
    [New Thread 0x7fa6ffd090 (LWP 8659)]
    [New Thread 0x7fa67fc090 (LWP 8660)]
    [New Thread 0x7fa5ffb090 (LWP 8661)]
    org.kde.kstars: Welcome to KStars 2.9.4
    org.kde.kstars: Build: 2018-04-12T19:22:22Z
    org.kde.kstars: OS: "ubuntu"
    org.kde.kstars: API: "arm64-little_endian-lp64"
    org.kde.kstars: Arch: "arm64"
    org.kde.kstars: Kernel Type: "linux"
    org.kde.kstars: Kernel Version: "4.9.190"
    [New Thread 0x7fa57fa090 (LWP 8662)]

    Thread 1 "kstars" received signal SIGSEGV, Segmentation fault.
    0x0000007fb2df62d8 in specific_new_surface ()
       from /usr/lib/aarch64-linux-gnu/libGLESv2.so.2
    (gdb) bt
    #0  0x0000007fb2df62d8 in specific_new_surface () from /usr/lib/aarch64-linux-gnu/libGLESv2.so.2
    #1  0x0000007fb2df7a90 in common_window_surface_new () from /usr/lib/aarch64-linux-gnu/libGLESv2.so.2
    #2  0x0000007fb2df7a90 in common_window_surface_new () from /usr/lib/aarch64-linux-gnu/libGLESv2.so.2
    #3  0x0000007fb2df7a90 in common_window_surface_new () from /usr/lib/aarch64-linux-gnu/libGLESv2.so.2
    #4  0x0000007fb2df7a90 in common_window_surface_new () from /usr/lib/aarch64-linux-gnu/libGLESv2.so.2
    #5  0x0000007fb2df7a90 in common_window_surface_new () from /usr/lib/aarch64-linux-gnu/libGLESv2.so.2
    #6  0x0000007fb2df7a90 in common_window_surface_new () from /usr/lib/aarch64-linux-gnu/libGLESv2.so.2

Same problem here…

Thread 1 "test" received signal SIGSEGV, Segmentation fault.
0x0000007fb5239e70 in specific_new_surface () from /usr/lib/aarch64-linux-gnu/libGLESv2.so