eyelash / tutorials

a collection of minimal example programs
The Unlicense
197 stars 59 forks source link

Return value is not checked for NULL #4

Open fschutt opened 7 years ago

fschutt commented 7 years ago

https://github.com/eyelash/tutorials/blob/30aaec4a896e90f6bda28ef1c99c9604731979b6/drm-gbm.c#L47

See http://manpages.ubuntu.com/manpages/xenial/man3/drmModeGetResources.3.html - function may return NULL, at which point a segfault will happen a few lines later.

eyelash commented 7 years ago

Thanks for pointing that out. I guess I should really take the time and go over the files in this repository and fix things (it's been over a year now that I last touched them). Generally, there is no error handling in any of the tutorials in order to improve the legibility. These examples are not meant to be copied and used as they are, instead they are more meant to give you an overview without having to read a thousand lines of code. Is drmModeGetResources returning NULL something that actually happens in practice?

fschutt commented 7 years ago

yeah, it segfaulted on me, which is why I noticed it. Tried running it from the regular Ubuntu desktop (17.04) with the Nvidia drivers installed (384.90) - doesn't work for whatever reason. Not sure how you are supposed to run the application.

I was originally interested in this in order to write a custom login application (like lightdm-greeter), but with wayland, is this possible with code such as this? Just asking, because I'm not very experienced in the linux graphics stack.

eyelash commented 7 years ago

I'm not sure the Nvidia closed source drivers supports DRM (some quick googling brought up this link), certainly not GBM (they came up with their own solution called EGLStreams, googling that should bring up quite a few news articles). Does Weston work for you? I don't really know much about login applications but I guess DRM and GBM could be used there.

Anderson0xFF commented 1 year ago

I also have the same problem, and I use AMD. Does anyone know of any solution? I have trouble understanding how Wayland works to build a simple composer.

Most of the codes I find are not documented, or are very complex, doing many things at the same time.

Anderson0xFF commented 1 year ago

@eyelash I know it seems like a lot to ask. But please, could you refactor the composer for a more current approach? I learned that the shell is no longer necessary. And could you leave some parts commented? I really need to understand how Wayland works to develop a DE. I've been looking for enough documentation for days to actually understand how to start from 0 to advanced in Wayland.

If it is necessary to make a small contribution $$, I am willing.

I really want to learn Wayland. I love Linux so much!

eyelash commented 1 year ago

@Anderson0xFF I haven't really done any Wayland development in the past few years. I would really like to get back to it one day but right now I don't really have the time. I don't think Wayland changed that much over the past years except for adding more additional protocols, so I'm expecting the fix for this issue to be rather simple but as I said I simply don't have the time. What I would recommend you to do is to read the code from different Wayland compositors such as Weston, wlroots, or Mutter, that's how I developed the code in this repo. Maybe use the code in this repo as a guide and grep for certain strings in the above compositors. Using an IDE that supports code navigation can also help a lot in understanding a bigger code base.