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

SDL_LoadObject error message truncated to 128 bytes long #5795

Closed
takase1121 opened this issue Jun 14, 2022 · 5 comments
Closed

SDL_LoadObject error message truncated to 128 bytes long #5795

takase1121 opened this issue Jun 14, 2022 · 5 comments

Comments

@takase1121
Copy link
Contributor

I'm working on a program that uses SDL_LoadObject to load a SO file. However, an error occured and I can't see the full error message because the SO file path is too long and obscured most of the error message. SDL_SetError() seems to have a 128 byte limit.

Error message:
Failed loading /home/takase/.luarocks/lib64/lua/5.4/ltreesitter.so: /home/takase/.luarocks/lib64/lua/5.4/ltreesitter.so: undefi

You can see that the string is truncated to 127 bytes.

I suggest to omit filenames in the error message. In this case, dlerror() somehow appends the filename and causes wastage.

@adamharrison
Copy link
Contributor

Also just randomly ran into this; independently of takase1121 (though we do randomly work on the same project).

@adamharrison
Copy link
Contributor

Seems like this can be changed by modifying the

#define ERR_MAX_STRLEN 128

line in SDL_error.c.h.

I'm assuming there's a reason this is so low. Would SDL be open to doubling, or quadrupling this number?

1bsyl added a commit that referenced this issue Jun 28, 2022
@1bsyl
Copy link
Contributor

1bsyl commented Jun 28, 2022

Previous commit fix an error, I got an error when the error message is reallocated.

==62914== Memcheck, a memory error detector
==62914== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==62914== Using Valgrind-3.20.0.GIT and LibVEX; rerun with -h for copyright info
==62914== Command: ./main.out
==62914== 
==62914== Invalid read of size 1
==62914==    at 0x484E636: __strlen_sse2 (vg_replace_strmem.c:500)
==62914==    by 0x523ADB0: __vfprintf_internal (vfprintf-internal.c:1517)
==62914==    by 0x524C519: __vsnprintf_internal (vsnprintf.c:114)
==62914==    by 0x495A9E2: SDL_vsnprintf_REAL (SDL_git/src/stdlib/SDL_string.c:1404)
==62914==    by 0x48A9ED8: SDL_SetError_REAL (SDL_git/src/SDL_error.c:47)
==62914==    by 0x4AAB1AC: SDL_LoadFunction_REAL (SDL_git/src/loadso/dlopen/SDL_sysloadso.c:72)
==62914==    by 0x4AB4D66: X11_GetSym (SDL_git/src/video/x11/SDL_x11dyn.c:80)
==62914==    by 0x4AB3BD8: SDL_X11_LoadSymbols (SDL_git/src/video/x11/SDL_x11sym.h:95)
==62914==    by 0x4AC292F: X11_CreateDevice (SDL_git/src/video/x11/SDL_x11video.c:159)
==62914==    by 0x49D00DC: SDL_VideoInit_REAL (SDL_git/src/video/SDL_video.c:453)
==62914==    by 0x48A7B59: SDL_InitSubSystem_REAL (SDL_git/src/SDL.c:251)
==62914==    by 0x48A80E2: SDL_Init_REAL (SDL_git/src/SDL.c:354)
==62914==  Address 0x1 is not stack'd, malloc'd or (recently) free'd
==62914== 
==62914== 
==62914== Process terminating with default action of signal 11 (SIGSEGV)
==62914==  Access not within mapped region at address 0x1
==62914==    at 0x484E636: __strlen_sse2 (vg_replace_strmem.c:500)
==62914==    by 0x523ADB0: __vfprintf_internal (vfprintf-internal.c:1517)
==62914==    by 0x524C519: __vsnprintf_internal (vsnprintf.c:114)
==62914==    by 0x495A9E2: SDL_vsnprintf_REAL (SDL_git/src/stdlib/SDL_string.c:1404)
==62914==    by 0x48A9ED8: SDL_SetError_REAL (SDL_git/src/SDL_error.c:47)
==62914==    by 0x4AAB1AC: SDL_LoadFunction_REAL (SDL_git/src/loadso/dlopen/SDL_sysloadso.c:72)
==62914==    by 0x4AB4D66: X11_GetSym (SDL_git/src/video/x11/SDL_x11dyn.c:80)
==62914==    by 0x4AB3BD8: SDL_X11_LoadSymbols (SDL_git/src/video/x11/SDL_x11sym.h:95)
==62914==    by 0x4AC292F: X11_CreateDevice (SDL_git/src/video/x11/SDL_x11video.c:159)
==62914==    by 0x49D00DC: SDL_VideoInit_REAL (SDL_git/src/video/SDL_video.c:453)
==62914==    by 0x48A7B59: SDL_InitSubSystem_REAL (SDL_git/src/SDL.c:251)
==62914==    by 0x48A80E2: SDL_Init_REAL (SDL_git/src/SDL.c:354)

@1bsyl
Copy link
Contributor

1bsyl commented Jun 28, 2022

@1bsyl
Copy link
Contributor

1bsyl commented Jun 28, 2022

Applied the same pattern. Anyway the code is not compiled because of #define DISABLE_JUMP_MAGIC 1

@slouken slouken closed this as completed Jun 28, 2022
PJB3005 pushed a commit to PJB3005/SDL that referenced this issue Oct 5, 2022
Also added SDL_GetOriginalMemoryFunctions()

Fixes libsdl-org#5795
PJB3005 pushed a commit to PJB3005/SDL that referenced this issue Oct 5, 2022
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

4 participants