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 image library detection selects the wrong lib #87

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

SDL image library detection selects the wrong lib #87

SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 1.2.12
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2014-11-29 06:17:43 +0000, Chris Beck wrote:

When creating a homebrew recipe for wesnoth, I discovered that the SDL image configuration routine does not detect libpng properly -- if you have multiple instances of libpng on your system, and you use environment variables to select an instance which is not in your system directory, the build can be broken, because it will run configuration tests against the system installed version, but deduce that it should use the filename of the system-installed version. In a vanilla build of wesnoth using homebrew, this results in segfaults at runtime, because you end up linking against two different versions of libpng, which is also needed independently of SDL.

The problem is essentially in the "find_lib" routine in the configure file:

find_lib()
{
gcc_bin_path=[$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g']
gcc_lib_path=[$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g']
env_lib_path=[echo $LIBS $LDFLAGS | sed 's/-L[ ]*//g']
for path in $gcc_bin_path $gcc_lib_path $env_lib_path /usr/lib /usr/local/lib; do
lib=[ls -- $path/$1 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q']
if test x$lib != x; then
echo $lib
return
fi
done
}

Because the for loop goes over the system directories before the environment directories, any system-installed lib will shadow the lib selected via environment variables. This is contrary to the behavior of the configuration tests earlier in the script, which prefers the environment variable libs over the system-installed libs. The 'for' loop should instead be:

for path in $env_lib_path $gcc_bin_path $gcc_lib_path /usr/lib /usr/local/lib; do

You can see the full discussion on the Homebrew / linuxbrew issue tracker here: Linuxbrew/legacy-linuxbrew#172

I have checked that this bug also affects SDL 1.2.15, SDL_mixer and SDL_ttf 1.2, which all use this same "find_lib" routine. I have not determined if the bug affects SDL 2.0, which seems not to use this exact routine.

On 2014-11-29 22:42:50 +0000, Sam Lantinga wrote:

Fixed, thanks!
https://hg.libsdl.org/SDL_image/rev/2b0ada991468

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