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

Busy loop within C library when calling SDL_Init() #3473

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed

Busy loop within C library when calling SDL_Init() #3473

SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

SDLBugzilla commented Feb 11, 2021

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.10
Reported for operating system, platform: Linux, Other

Comments on the original bug report:

On 2019-12-08 14:41:23 +0000, Paul Cercueil wrote:

Running a basic SDL2 app on a MIPS-based Buildroot system running uClibc or musl (glibc untested) results in SDL_Init() locking up and eating the CPU in the process.

From a quick GDB session on the uClibc-based system, it appears to busy-loop in _dl_find_hash() (uclibc-1.0.32/ldso/ldso/dl-hash.c).

The fact that it happens with both musl and uClibc, and only with SDL2 and no other library or app, makes me think it's a bug of SDL2.

On 2019-12-08 14:54:07 +0000, Ryan C. Gordon wrote:

This function generally means the dynamic loader is resolving symbols. If you observed this under the debugger, can you run the “bt” command and paste the output here? It’s probably going to be somewhere under a dlopen() call.

--ryan.

On 2019-12-08 17:54:12 +0000, Paul Cercueil wrote:

Unfortunately it doesn't go very far:

(gdb) bt

0 0x77e6ab88 in _dl_find_hash () from /lib/ld-uClibc.so.0

1 0x77e6aba4 in _dl_find_hash () from /lib/ld-uClibc.so.0

Backtrace stopped: frame did not save the PC

(and yes, I compiled SDL2 with -ggdb3 and GDB did load the symbols).

On 2019-12-08 18:32:22 +0000, Paul Cercueil wrote:

I added debug to src/loadso/dlopen/SDL_sysloadso.c.
From what I can see, it seems to hang within dlopen(), when libdrm.so.2 is opened for the second time.

See below:

gcw0:~ $ gdb ./testsdl2
[...]
(gdb) r
Starting program: /media/data/local/home/testsdl2
[New LWP 264]
SDL dlopen(libdrm.so.2)... done
SDL dlopen(libgbm.so.1)... done
SDL dlsym(drmModeFreeResources)... done
SDL dlsym(drmModeFreeFB)... done
SDL dlsym(drmModeFreeCrtc)... done
SDL dlsym(drmModeFreeConnector)... done
SDL dlsym(drmModeFreeEncoder)... done
SDL dlsym(drmModeGetResources)... done
SDL dlsym(drmModeAddFB)... done
SDL dlsym(drmModeRmFB)... done
SDL dlsym(drmModeGetFB)... done
SDL dlsym(drmModeGetCrtc)... done
SDL dlsym(drmModeSetCrtc)... done
SDL dlsym(drmModeSetCursor)... done
SDL dlsym(drmModeSetCursor2)... done
SDL dlsym(drmModeMoveCursor)... done
SDL dlsym(drmModeGetEncoder)... done
SDL dlsym(drmModeGetConnector)... done
SDL dlsym(drmHandleEvent)... done
SDL dlsym(drmModePageFlip)... done
SDL dlsym(gbm_device_get_fd)... done
SDL dlsym(gbm_device_is_format_supported)... done
SDL dlsym(gbm_device_destroy)... done
SDL dlsym(gbm_create_device)... done
SDL dlsym(gbm_bo_get_width)... done
SDL dlsym(gbm_bo_get_height)... done
SDL dlsym(gbm_bo_get_stride)... done
SDL dlsym(gbm_bo_get_handle)... done
SDL dlsym(gbm_bo_write)... done
SDL dlsym(gbm_bo_get_device)... done
SDL dlsym(gbm_bo_set_user_data)... done
SDL dlsym(gbm_bo_get_user_data)... done
SDL dlsym(gbm_bo_destroy)... done
SDL dlsym(gbm_bo_create)... done
SDL dlsym(gbm_surface_create)... done
SDL dlsym(gbm_surface_destroy)... done
SDL dlsym(gbm_surface_lock_front_buffer)... done
SDL dlsym(gbm_surface_release_buffer)... done
SDL dlopen(libdrm.so.2)...

On 2019-12-17 22:38:53 +0000, Paul Cercueil wrote:

Small update: this bug does not happen if libdrm is pre-loaded:

SDL_PRELOAD=/usr/lib/libdrm.so.2 ./testsdl2

works fine.

On 2019-12-17 23:33:44 +0000, Paul Cercueil wrote:

Created attachment 4113
Patch to fix bug 4891

On 2019-12-20 05:48:06 +0000, Sam Lantinga wrote:

Patch added, thanks!
https://hg.libsdl.org/SDL/rev/4f5bef55183c

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

1 participant