Jump to content
  • Advertisement
Sign in to follow this  
KarimIO

glDrawElementsBaseVertex causes segfault on Linux but no issues on Windows

This topic is 653 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys. I'm trying to make my engine cross platform but I've stumbled across an issue. I'm trying to use the command glDrawElementsBaseVertex, and this works perfectly in Windows, but not at all in Linux. I've traced the problem to there, and I checked that my VAO is bound and that all the parameters to the function are exactly the same. Where could I find the source of this issue? I'm using gl3w if that's relevant (because glew is outdated). I can't really show my entire code here because it's thousands upon thousands of lines across multiple DLLs, but if you'd like to take a look at something I could paste that section here. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement

The OS is not relevant.

 

What is relevant is the hardware and drivers.  If either don't support that entry point, then the function pointer for it will be NULL, and it will crash if you try to use it.

Share this post


Link to post
Share on other sites

The OS is not relevant.

 

What is relevant is the hardware and drivers.  If either don't support that entry point, then the function pointer for it will be NULL, and it will crash if you try to use it.

 

this...

 

Make sure you validate your function pointers!

Share this post


Link to post
Share on other sites

What kind of segfault is it? Read or write? Do you know the memory address?

 

Implementations of GL often crash inside glDraw* functions because you've passed an invalid pointer to an early state/resource setting function, which the implementation has simply cached for use on the next draw call.

Share this post


Link to post
Share on other sites

The OS is not relevant.
 
What is relevant is the hardware and drivers.  If either don't support that entry point, then the function pointer for it will be NULL, and it will crash if you try to use it.

  

The OS is not relevant.
 
What is relevant is the hardware and drivers.  If either don't support that entry point, then the function pointer for it will be NULL, and it will crash if you try to use it.

 
this...
 
Make sure you validate your function pointers!
  

What kind of segfault is it? Read or write? Do you know the memory address?
 
Implementations of GL often crash inside glDraw* functions because you've passed an invalid pointer to an early state/resource setting function, which the implementation has simply cached for use on the next draw call.


I did try check the function address before posting this topic and it seemed to be working fine. I did an upgrade and I'm pretty sure I have the latest driver version installed. I'm not super experienced with Linux development so how can I tell you the default state? And if I use the same code for Linux and windows (aside from windowing code), shouldn't the pointer be valid?

Share this post


Link to post
Share on other sites

And if I use the same code for Linux and windows (aside from windowing code), shouldn't the pointer be valid?

Not necessarily. GL is a specification, not a library. Different drivers contain different libraries that attempt to comply with that specification, each with their own actual behaviours.

If you're using GL in a way that the spec says that you're not allowed to, then perhaps one implementation is pessimistic and contains error handling to tolerate buggy apps, while the other implementation assumes that all apps also follow the spec and encounters undefined behaviour when apps don't.

Also if it's a bug in your code where you're passing an invalid pointer, then it comes down to the details of that bug. Perhaps it's a "use after free bug", but on Windows the memory allocator hasn't unmapped the pages used by that allocation (meaning that reading from the "free'ed" memory won't actually crash), while on Linux the pages are unmapped immediately, leading to a segfault when GL attempts to read from them.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!