0

I'm developing a Java graphical application with jogl and OpenGL at the Linux. My application contains over 30 shaders and they work fine in most cases. But about once a week there is a driver (amdgpu pro) error (SIGSEGV).

Please tell me, is OpenGL safe language: It is protected from errors by the application program or incorrect actions of the application can cause damage to the memory of the driver (writing to someone else's memory or data race). In what do I look for the cause of the error (SIGSEGV) in the incorrect driver (amdgpu pro) or in the errors of the application itself? (The glGetError show that all fine at each application step).

  • 3
    OpenGL is not a language. The driver implementation is just a program which can contain bugs. Improper or nonstandard use of the API can potentially cause crashes. – Bartek Banachewicz Sep 28 '17 at 13:25
  • What application actions can lead to driver crash (SIGSEGV) if there are no obvious errors and glGetError shows that there are no problems? Are there debugging tools to detect such incorrect application actions automatically? – Roman Yurin Sep 28 '17 at 13:37

2 Answers2

4

In general, there are going to be plenty of ways to crash your program when you are using the OpenGL API. Buggy drivers are an unfortunate reality that you cannot avoid completely, and misuse of the API in creative ways can cause crashes instead of errors. In fact, I have personally caused computers to completely hang (unresponsive) on multiple platforms and different GPU vendors, even when using WebGL which is supposedly "safe".

So the only possible answer is "no, OpenGL is not safe."

Some tips for debugging OpenGL:

  • Don't use glGetError, use KHR_debug instead (unless it's not available).

  • Create a debug context with GL_CONTEXT_FLAG_DEBUG_BIT.

  • Use a less buggy OpenGL implementation when you are testing. In my experience, the Mesa implementation is very stable.

Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415
  • 1
    seriously, strongly consider getting rid of all `glGetError` calls in favor of `KHR_debug`. `KHR_debug` will give you the same info as `glGetError` and if configured to, will allow you to set up break points when the error happened, where as `glGetError` just means the error happened before it was called.. – tamato Sep 29 '17 at 17:57
3

Is OpenGL 4.3 "safe"? Absolutely not. There are many things you can do that can crash the program. Having a rendering operation read from past the boundaries of a buffer, for example. 4.3 has plenty of ways of doing that.

Indeed, simply writing a shader that executes for too long can cause a GPU failure.

You could in theory read GPU memory that was written by some other application, just by reading from an uninitialized buffer.

There is no simple way to tell whether a particular crash was caused by a driver bug or by user error. You have to actually debug it and have a working understanding of the OpenGL specification to know for sure.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982