Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return value is not checked for NULL #4

Open
fschutt opened this issue Oct 4, 2017 · 6 comments
Open

Return value is not checked for NULL #4

fschutt opened this issue Oct 4, 2017 · 6 comments

Comments

@fschutt
Copy link

fschutt commented Oct 4, 2017

drmModeRes *resources = drmModeGetResources (device);

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
Copy link
Owner

eyelash commented Oct 4, 2017

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
Copy link
Author

fschutt commented Oct 4, 2017

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
Copy link
Owner

eyelash commented Oct 4, 2017

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.

dwrobel added a commit to dwrobel/tutorials that referenced this issue Nov 28, 2019
 Program received signal SIGSEGV, Segmentation fault.
 xkb_context_ref (ctx=ctx@entry=0x0) at /usr/src/debug/libxkbcommon/0.5.0-r0/libxkbcommon-0.5.0/src/context.c:152
 152	    ctx->refcnt++;
 (gdb) bt
 #0  xkb_context_ref (ctx=ctx@entry=0x0) at /usr/src/debug/libxkbcommon/0.5.0-r0/libxkbcommon-0.5.0/src/context.c:152
 eyelash#1  0xb660efb8 in xkb_keymap_new (ctx=0x0, format=format@entry=XKB_KEYMAP_FORMAT_TEXT_V1, flags=XKB_KEYMAP_COMPILE_NO_FLAGS) at /usr/src/debug/libxkbcommon/0.5.0-r0/libxkbcommon-0.5.0/src/keymap-priv.c:65
 eyelash#2  0xb660ec42 in xkb_keymap_new_from_buffer (ctx=ctx@entry=0x0, buffer=buffer@entry=0xb605c000 "xkb_keymap {\nxkb_keycodes \"evdev-onemw_aliases(qwerty)\" {\n\tminimum = 8;\n\tmaximum = 446;\n\t<ESC>", ' ' <repeats 16 times>, "= 9;\n\t<AE01>", ' ' <repeats 15 times>, "= 10;\n\t<AE02>", ' ' <repeats 15 times>, "= 11;\n\t<AE03>", ' ' <repeats 15 times>, "= 12;\n\t"..., length=48673, format=format@entry=XKB_KEYMAP_FORMAT_TEXT_V1, flags=flags@entry=XKB_KEYMAP_COMPILE_NO_FLAGS) at /usr/src/debug/libxkbcommon/0.5.0-r0/libxkbcommon-0.5.0/src/keymap.c:191
 eyelash#3  0xb660eca2 in xkb_keymap_new_from_string (ctx=0x0, string=0xb605c000 "xkb_keymap {\nxkb_keycodes \"evdev-onemw_aliases(qwerty)\" {\n\tminimum = 8;\n\tmaximum = 446;\n\t<ESC>", ' ' <repeats 16 times>, "= 9;\n\t<AE01>", ' ' <repeats 15 times>, "= 10;\n\t<AE02>", ' ' <repeats 15 times>, "= 11;\n\t<AE03>", ' ' <repeats 15 times>, "= 12;\n\t"..., format=XKB_KEYMAP_FORMAT_TEXT_V1, flags=XKB_KEYMAP_COMPILE_NO_FLAGS) at /usr/src/debug/libxkbcommon/0.5.0-r0/libxkbcommon-0.5.0/src/keymap.c:162
 eyelash#4  0x000094ec in keyboard_keymap ()
 eyelash#5  0xb636f718 in ffi_call_VFP () at ../libffi-3.2.1/src/arm/sysv.S:377
 eyelash#6  0xb636fd2e in ffi_call (cif=cif@entry=0xbefff714, fn=<optimized out>, rvalue=rvalue@entry=0x0, avalue=avalue@entry=0xbefff7d4) at /usr/src/debug/libffi/3.2.1-r0/libffi-3.2.1/src/arm/ffi.c:344
 eyelash#7  0xb6630e46 in wl_closure_invoke (closure=closure@entry=0x1be28, flags=flags@entry=1, target=<optimized out>, target@entry=0x1bd58, opcode=opcode@entry=0, data=<optimized out>) at /usr/src/debug/wayland/1.11.0-r0/wayland-1.11.0/src/connection.c:935
 #8  0xb662f1fa in dispatch_event (display=display@entry=0x17378, queue=<optimized out>) at /usr/src/debug/wayland/1.11.0-r0/wayland-1.11.0/src/wayland-client.c:1310
 #9  0xb662fc94 in dispatch_queue (queue=0x173e4, display=0x17378) at /usr/src/debug/wayland/1.11.0-r0/wayland-1.11.0/src/wayland-client.c:1456
 #10 wl_display_dispatch_queue_pending (display=display@entry=0x17378, queue=queue@entry=0x173e4) at /usr/src/debug/wayland/1.11.0-r0/wayland-1.11.0/src/wayland-client.c:1698
 #11 0xb662fd6c in wl_display_dispatch_queue (display=0x17378, queue=0x173e4) at /usr/src/debug/wayland/1.11.0-r0/wayland-1.11.0/src/wayland-client.c:1674
 #12 0xb662ff1c in wl_display_roundtrip_queue (display=0x17378, queue=0x173e4) at /usr/src/debug/wayland/1.11.0-r0/wayland-1.11.0/src/wayland-client.c:1121
 #13 0xb662ff44 in wl_display_roundtrip (display=<optimized out>) at /usr/src/debug/wayland/1.11.0-r0/wayland-1.11.0/src/wayland-client.c:1150
 #14 0xb6ff5d4c in eglGetDisplay (display_id=<optimized out>) at /usr/src/debug/wayland-egl/rdkv-20180926+gitnightly_master_tag_09262018-r0/git/wayland-egl/wayland-egl.c:522
 #15 0x00009a50 in main ()
 (gdb) p ctx
 $1 = (struct xkb_context *) 0x0
@Anderson0xFF
Copy link

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
Copy link

@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
Copy link
Owner

eyelash commented Nov 5, 2023

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants