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

NULL pointer dereference on integrated GPU #4

Open
nikitkagood opened this issue Oct 4, 2021 · 3 comments
Open

NULL pointer dereference on integrated GPU #4

nikitkagood opened this issue Oct 4, 2021 · 3 comments

Comments

@nikitkagood
Copy link
Contributor

Hi, I have my little OpenGL project that uses SOIL.
On my home PC with RX 580 it runs just fine. On my working PC with i7-9700 and Intel UHD Graphics 630 there is an error in function query_NPOT_capability(void), line strstr( (char const*)glGetString( GL_EXTENSIONS ), "GL_ARB_texture_non_power_of_two" ) ).
Because (char const*)glGetString( GL_EXTENSIONS ) returns null pointer and strstr tries to dereference it.

Why do I think this is an integrated GPU issue? Well, can't say for sure. I've seen assumptions of it on the internet. Then I made an experiment which kinda proved it.

I also made a simple fix by adding NULL check.

@jwerle jwerle closed this as completed Oct 4, 2021
@arf20
Copy link

arf20 commented Oct 14, 2022

The issue is still not fixed. jwerle has not implemented the simple NULL check.
And now I'm the one getting segfault at the strstr() call in soil.c:1903

__strstr_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S:40
40      ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S: No such file or directory.
(gdb) bt
#0  __strstr_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S:40
#1  0x00007ffff798477d in query_NPOT_capability () from /usr/lib/libSOIL.so.1
#2  0x00007ffff7984b4d in SOIL_internal_create_OGL_texture () from /usr/lib/libSOIL.so.1
#3  0x00007ffff7986af0 in SOIL_load_OGL_texture () from /usr/lib/libSOIL.so.1
#4  0x0000555555573a81 in loadEarthTexture (path="/usr/local/share/arftracksat/earth.png") at /home/arf20/sources/arftracksat/representation/asset_loader.cpp:60
#5  0x000055555559e380 in startGraphics (shownSats=std::vector of length 46, capacity 64 = {...}, sta=..., mapfile="/usr/local/share/arftracksat/map.json", texturefile="/usr/local/share/arftracksat/earth.png")
    at /home/arf20/sources/arftracksat/representation/graphics.cpp:321
#6  0x00005555555a2da6 in main (argc=1, argv=0x7fffffffdfd8) at /home/arf20/sources/arftracksat/src/main.cpp:200```

@jwerle jwerle reopened this Oct 14, 2022
@nikitkagood
Copy link
Contributor Author

nikitkagood commented Oct 15, 2022

Hi everyone. I'm not sure whether arf20 comment implies I am ought to do something.

I haven't been working with OpenGL (and therefore with SOIL) for quite some time, so I'd rather choose to not dig into the problem too much. And I don't have integrated graphics for tests anymore anyway.

There is pull request from me even though it's not attached to the issue. It does implement fix (i.e the simple pointer NULL check) to my problem in function query_NPOT_capability. It shouldn't be too hard to make the same fix yourself. Just in another function (soil.c:1903 ->query_tex_rectangle_capability). And obviously to test it straight away.

I have to point out my fix might be a bit wrong. Cause if glGetString_extentions_ptr != NULL -> "capability none" and thus if ptr == NULL -> "capability present" (soil.c:1880), which probably has to be the other way around. But maybe I did it this way because "capability none" actually resulted in other problems.

If there is need for a simple solution.

Considering there are many simillar functions and glGetString everywhere and the docs say "If an error is generated, glGetString returns 0". There might be a deeper look required. I.e. catching the error before everything crashes and then looking into it. Previously I missed this part cause I was too newbie I guess.

But like I said I'd rather not write any code myself, sorry.

@arf20
Copy link

arf20 commented Oct 15, 2022

I did not mean to annoy you, sorry.
I forgot to mention that this is no longer an iGPU problem only, but I did post in this thread because it already mentions the culprit.

SOIL segfaults when using remote X11 servers such as VcXSrv on Windows.

While there is a pull request, and it is merged, I chose to use SOIL because it was already in the debian repository, which is not yet updated.

So I moved to use std_image.h instead. Thank you anyway.

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