KhronosGroup / KTX-Software

KTX (Khronos Texture) Library and Tools
Other
854 stars 226 forks source link

Loading KTX1 and KTX2 file on Linux/OpenGL 4.3 leads to weird error if not luch the program with sudo #862

Closed Raffaello closed 5 months ago

Raffaello commented 6 months ago

the same sample tests are running fine on Windows.

Is there any reasons that requires sudo permission to upload a KTX texture in a GL context?


a similar issue here: https://github.com/KhronosGroup/KTX-Software/issues/708

but in this case i have the gl functions working properly, only with libKTX have issue on Linux Fedora when do a GLUpload and at the same time if the process is running with a sudo no error happens.

MarkCallow commented 6 months ago

Is there any reasons that requires sudo permission to upload a KTX texture in a GL context?

No. I have no idea why it should work with sudo and fail without. I do not have access to a Fedora system so cannot test. I use Ubuntu with either an Intel integrated GPU or the Parallels VM driver over an Apple M2 and everything works fine. I also have no idea why behaviour is different for ktx1 and ktx2 files. The messages you see in the ktx1 non-sudo case are consistent with the problem described in issue #708. Perhaps Fedora does not let applications use dlsym on their own modules without sudo.

What GPU hardware are you using?

Where is the segmentation fault happening. Please provide a stack trace?

To confirm if this is the same issue as #708 or not please try adding void *libGL = dlopen("libGL.so", RTLD_NOW | RTLD_GLOBAL); in your app before calling GLUpload the first time. If this works, RTLD_LAZY should work too and will be faster. If it does work, please use this workaround until the loadGL function mentioned in #708 has been added to libktx.

Raffaello commented 6 months ago

thanks @MarkCallow .

I can confirm there is no issue on Ubuntu.

on Fedora adding void *libGL = dlopen("libGL.so", RTLD_NOW | RTLD_GLOBAL); before GLUpload solve the issue for both ktx1 and ktx2.

I can confirm it is the same issue of #708, but small differences on there:

I don't know what can be in Fedora, but it looks something related to security/permissions of a so loading sharing a user process context/memory with a shared library or something? Not sure just a guess. It could be a bug in Fedora distro as well.

or simply it can be that KTX on Fedora must do an explicit operation when doing GLUpload like dlopen ? but again can't say just another guess...

maybe the simplest thing is the build and RPM are not generated correctly and doesn't create the link to gl so library as if i recall correctly is done through an ubuntu machine. (if i can find some time i wll try do a build from source in fedora)

Raffaello commented 6 months ago

FYI: just compiled natively on fedora, just to tick that out, the error is still present like if it was compiled in ubuntu without the dlopen pre-statement to GLUpload. So it shouldn't be a cross-linux-distro compilation issue.

MarkCallow commented 5 months ago

This is a duplicate of #708. Whether the fact that the current code works with sudo is specific to this case or would also work in #708's case I do not know. It doesn't matter as the fix will be the same.