Bug 1471427

Summary: glibc: Disable multi-arch (IFUNC) feature on i386 to support legacy applications
Product: [Fedora] Fedora Reporter: James <fedorabugmail>
Component: glibcAssignee: Florian Weimer <fweimer>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 26CC: arjun.is, bugzilla.redhat.com, codonell, dan.doel, darakus, dj, fweimer, gilboad, joshua.rich, juergen.stohr, law, LordSamanon, mfabian, mikhail.v.gavrilov, mpovolny, mymindstorm, pfrankli, siddhesh, tbeckman, will.leonardi
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: glibc-2.26-2.fc27 glibc-2.25-8.fc26 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-21 13:50:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Civ5 stack trace with glibc-debuginfo package installed
none
GDB info from Borderlands 2
none
Civ5 stack trace, registers and disassemble output none

Description James 2017-07-15 21:25:43 UTC
Description of problem:
After running a blank screen is briefly displayed then a segmentation fault happens. The last library call is libc. This app worked fine in F25.

Version-Release number of selected component (if applicable):
glibc-2.25-7.fc26.i686

How reproducible:
Reliable every time. 

Additional info: GDB output
[New Thread 0xf46ffb40 (LWP 2764)]
[New Thread 0xf1a32b40 (LWP 2765)]
[New Thread 0xf1831b40 (LWP 2766)]
warning: Corrupted shared library list: 0xf5579d10 != 0x103f91f8
[New Thread 0xefb8cb40 (LWP 2767)]

Thread 3 "Civ5XP" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xf5ed3b40 (LWP 2763)]
0xf7a3c9b3 in __strspn_sse42 () from /lib/libc.so.6

(gdb) backtrace
#0  0xf7a3c9b3 in __strspn_sse42 () from /lib/libc.so.6
#1  0xf443ff9d in parse_line (state=0xf5ecf118) at pulsecore/conf-parser.c:85
#2  pa_config_parse (filename=0xf4793ce8 "/etc/pulse/client.conf", f=f@entry=0xf4794160, t=t@entry=0xf5ed01a0, 
    proplist=proplist@entry=0x0, use_dot_d=use_dot_d@entry=true, userdata=userdata@entry=0x0)
    at pulsecore/conf-parser.c:202
#3  0xf442d88f in pa_client_conf_load (c=0xf4793b80, load_from_x11=load_from_x11@entry=true, 
    load_from_env=load_from_env@entry=true) at pulse/client-conf.c:153
#4  0xf44b5187 in pa_context_new_with_proplist (mainloop=mainloop@entry=0xf47dc110, name=name@entry=0xf5ed0340 "Civ5XP", 
    p=p@entry=0x0) at pulse/context.c:171
#5  0xf44b5339 in pa_context_new (mainloop=0xf47dc110, name=0xf5ed0340 "Civ5XP") at pulse/context.c:103
#6  0xf784ef48 in ?? () from ./libopenal.so.1
#7  0xf784f4ab in ?? () from ./libopenal.so.1
#8  0xf7851e06 in ?? () from ./libopenal.so.1
#9  0xf78270a3 in alcOpenDevice () from ./libopenal.so.1
#10 0x09126f34 in YUV12 ()
#11 0x091264a2 in YUV12 ()
#12 0x09113bee in check_for_pending_io ()
#13 0x09114188 in BinkOpen ()
#14 0x085f7553 in ASL::PlayBinkMovieGL(char const*, float, unsigned int, unsigned int, bool*) ()
#15 0x0884c26c in PlayMovieState::Begin() ()
#16 0x086e0fc3 in Civ5App::PlayOpeningMovie() ()
#17 0x086e1c46 in Civ5App::Init(char const*) ()
#18 0x0865b3ed in WinMain ()
#19 0x085f5487 in ?? ()
#20 0x085d8e3e in ThreadHANDLE::ThreadProc(void*) ()
#21 0xf7b912d9 in start_thread () from /lib/libpthread.so.0
#22 0xf79da296 in clone () from /lib/libc.so.6

Comment 1 Dan Doel 2017-07-15 21:33:52 UTC
Hello, I may have found some relevant information for this bug. I'm experiencing the same problem with the two ported Borderlands games.

This arch bug seems to be the same issue:

  https://bugs.archlinux.org/task/54136?project=0&order=id&sort=desc&string=glibc

I'm not clear if their diagnosis that it is a GCC issue is correct. But they also have a work-around.

Comment 2 Florian Weimer 2017-07-17 09:08:06 UTC
Please install debuginfo packages for glibc and report the exact fault location using the “disassemble” GDB command.  Please include “info registers” output as well.

Comment 3 Joshua Rich 2017-07-17 11:30:31 UTC
Created attachment 1299784 [details]
Civ5 stack trace with glibc-debuginfo package installed

Same issue for me, same program (Civilisation V installed via Steam Linux).  I installed the glibc-debuginfo package and ran gdb against the coredump as per https://fedoraproject.org/wiki/StackTraces.  Is this useful?

Comment 4 Florian Weimer 2017-07-17 13:58:14 UTC
(In reply to Joshua Rich from comment #3)
> Created attachment 1299784 [details]
> Civ5 stack trace with glibc-debuginfo package installed
> 
> Same issue for me, same program (Civilisation V installed via Steam Linux). 
> I installed the glibc-debuginfo package and ran gdb against the coredump as
> per https://fedoraproject.org/wiki/StackTraces.  Is this useful?

Looks like you didn't install the 32-bit debuginfo packages.  I'd also need the diassamble output and the register contents.  Thanks.

Comment 5 Dan Doel 2017-07-17 17:55:02 UTC
Created attachment 1300021 [details]
GDB info from Borderlands 2

Does this work? It's the information for Borderlands 2.

GDB suggests installing more debuginfo packages, but dnf says they are already installed.

Comment 6 Joshua Rich 2017-07-18 11:54:21 UTC
Created attachment 1300442 [details]
Civ5 stack trace, registers and disassemble output

Check the following compressed archive for the trace (with i686 debuginfo packages installed), registers and disassemble output.  Hope this is helpful, let me know if I need to provide any other info!

Comment 7 Florian Weimer 2017-07-18 13:47:09 UTC
Thanks, Dan and Joshua.  This is a stack alignment issue.  The binaries do not comply with the current i386 API, so a lot of SSE2-optimized code in libraries will break.  This issue is not specific to glibc, but shows up mostly with glibc at present because we do not build the whole distribution with SSE2 support.

Comment 8 Dan Doel 2017-07-18 22:17:35 UTC
Do you know what is likely to have caused this? Is it just due to the binaries being compiled with a different GCC version than Fedora uses? Or would it be an actual error in the source code?

Comment 9 Carlos O'Donell 2017-07-19 01:58:18 UTC
(In reply to Dan Doel from comment #8)
> Do you know what is likely to have caused this? Is it just due to the
> binaries being compiled with a different GCC version than Fedora uses? Or
> would it be an actual error in the source code?

The most comment scenario observed is code compiled with Intel's icc compiler in conjunction with options that break the ABI. The developer perhaps doesn't know that the option, specifically -falign-stack=4, will cause problems when entering SSE2 code.

Comment 10 Martin Povolny 2017-08-01 11:23:07 UTC
I understand that this might not classify as a "Fedora bug", but what is the plan dealing with this?

Are we expecting Valve and other vendors to recompile binaries or is this going to be addressed on Fedora side?

This is going to be a blocker for many Fedora home users. It should be propably mentioned in the release notes at least. Something like "Expect Steam games to crash unde F26".

Thanks!

Comment 11 Carlos O'Donell 2017-08-01 13:28:20 UTC
(In reply to Martin Povolny from comment #10)
> I understand that this might not classify as a "Fedora bug", but what is the
> plan dealing with this?

There is currently no plan to fix this, the developer has broken the ABI by compiling their application with options that change the ABI.

The glibc team has been discussing that in Fedora we could probably switch glibc to be compiled in a more compatible fashion, disabling SSE2, and building a very vanilla i686 build. This would fix this issue for glibc only.

That still leaves you to find and fix any dependent libraries that use SSE2 and require an aligned stack, but don't automatically align the stack themselves.
 
> Are we expecting Valve and other vendors to recompile binaries or is this
> going to be addressed on Fedora side?

What Valve and the vendors do is up to them.

If Valve and the vendors compile their code with options that don't follow the ABI, then the applications will not run correctly.

They will have the same problem in all the other distributions that use SSE2 optimizations.

> This is going to be a blocker for many Fedora home users. It should be
> propably mentioned in the release notes at least. Something like "Expect
> Steam games to crash unde F26".

Sure, how about:

"In Fedora 26 it has been found that some games distributed under STEAM may fail to start or crash. These 32-bit games crash because they have been incorrectly built (don't follow the i686 stack alignment requirements) and the authors of such games should rebuild as redistribute as needed."

How do we get this into the Fedora 26 release notes?

Comment 12 Matthew Bunt 2017-08-01 18:42:25 UTC
(In reply to Martin Povolny from comment #10)

> This is going to be a blocker for many Fedora home users.

I feel like I have to choose between Fedora and Gaming. And that is a terrible feeling.

Comment 13 tbeckman 2017-08-02 03:51:27 UTC
Using a flatpak install of Steam works around the issue for me for at least Civilization Beyond Earth (haven't had time to test other games).  These are the commands I ran to get it installed and running:

1) Add the flathub faltpak repo:

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

2) Install the steam flatpak:

flatpak install flathub com.valvesoftware.Steam

3) Run the steam flatpak:

flatpak run com.valvesoftware.Steam/x86_64/stable


Assuming this works for other Aspyr games, at least we don't have to choose between Fedora and gaming.

Comment 14 Dan Doel 2017-08-03 01:01:47 UTC
Unfortunately, the Borderlands games crash at other points when run with the flatpak steam (though it does fix the crashes due to videos).

Comment 15 tbeckman 2017-08-03 03:18:32 UTC
I was able to play Borderlands The Pre-Sequel with flatpak steam for 30 minutes without issues if I set Steam to offline mode before starting Borderlands.  With it in online mode it crashes about when the menu should come up.  I haven't tried to figure out the cause.

Comment 16 Brendan Early 2017-08-03 03:22:40 UTC
Have you tried compiling glibc with -mstackrealign like arch did? That fixed Civ 5 for me.

Comment 17 tbeckman 2017-08-07 03:42:40 UTC
Do you have a quick how-to for building glibc in 32-bit mode and getting steam games to use it?

Comment 18 Brendan Early 2017-08-07 21:15:48 UTC
I don't know about compiling it in 32-bit mode, but Civ 5 has a folder that it uses for libraries (~/.steam/steam/steamapps/common/Sid Meier's Civilization V/ iirc). So if you compile it with -mstackrealign added, then extract the offending libraries (Civ 5 needs libc-2.25 and libc.so.6) into "~/.steam/steam/steamapps/common/Sid Meier's Civilization V/" and put them there.

Comment 19 tbeckman 2017-08-08 02:23:04 UTC
Compiling a 32-bit version of glibc and placing the resulting libc.so and libc.so.6 symlink into the ~/.steam/steam/steamapps/common/<game subdir> works for both Civ Beyond Earth and Borderlands The Pre-Sequel.

The config options I used to build it were:

../glibc/configure --prefix=$HOME/glibc/build \
     --host=i686-linux-gnu \
     --build=i686-linux-gnu \
     CC="gcc -m32" CXX="g++ -m32" \
     CFLAGS="-O2 -march=i686 -mstackrealign" \
     CXXFLAGS="-O2 -march=i686 -mstackrealign"

In case that helps someone else figure it out.

I still hope Fedora makes this the default method to build for the 32-bit glibc for Fedora 26.  If a program worked on Fedora 25, it seems like the best thing for users is to sacrifice a little performance in favor of having it continue to work, especially for 32-bit applications.  At least until companies like Aspyr get their build straightened out.

Comment 20 Sam 2017-08-08 05:11:29 UTC
OpenSUSE is also dealing with this issue. https://bugzilla.opensuse.org/show_bug.cgi?id=1048861

Comment 21 Fedora Update System 2017-08-16 12:27:21 UTC
glibc-2.25-8.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-92f8958310

Comment 22 Gilboa Davara 2017-08-18 08:44:46 UTC
(In reply to tbeckman from comment #19)
> Compiling a 32-bit version of glibc and placing the resulting libc.so and
> libc.so.6 symlink into the ~/.steam/steam/steamapps/common/<game subdir>
> works for both Civ Beyond Earth and Borderlands The Pre-Sequel.
> 
> The config options I used to build it were:
> 
> ../glibc/configure --prefix=$HOME/glibc/build \
>      --host=i686-linux-gnu \
>      --build=i686-linux-gnu \
>      CC="gcc -m32" CXX="g++ -m32" \
>      CFLAGS="-O2 -march=i686 -mstackrealign" \
>      CXXFLAGS="-O2 -march=i686 -mstackrealign"
> 
> In case that helps someone else figure it out.
> 
> I still hope Fedora makes this the default method to build for the 32-bit
> glibc for Fedora 26.  If a program worked on Fedora 25, it seems like the
> best thing for users is to sacrifice a little performance in favor of having
> it continue to work, especially for 32-bit applications.  At least until
> companies like Aspyr get their build straightened out.

glibc alone worked? You didn't have to pull / rebuild additional libs?

- Gilboa

Comment 23 Gilboa Davara 2017-08-18 08:45:41 UTC
@fweimer,

Is this bug fixed or is WONTFIX? I'm a bit confused...

- Gilboa

Comment 24 Florian Weimer 2017-08-18 09:00:59 UTC
(In reply to Gilboa Davara from comment #23)
> @fweimer,
> 
> Is this bug fixed or is WONTFIX? I'm a bit confused...

I have submitted an update for Fedora 26, see comment 21.

Comment 25 Florian Weimer 2017-08-18 09:02:53 UTC
(In reply to Gilboa Davara from comment #22)
> glibc alone worked? You didn't have to pull / rebuild additional libs?

Other libraries may use SSE2 or other problematic instruction sets after run time detection, but this is still relatively rare.  The bulk of Fedora is compiled in such a way that SSE2 capabilities are not used, so the impact of the new GCC vectorization capabilities is greatly reduced compared to what other distributions see.

Comment 26 Gilboa Davara 2017-08-19 14:19:36 UTC
(In reply to Florian Weimer from comment #24)
> (In reply to Gilboa Davara from comment #23)
> > @fweimer,
> > 
> > Is this bug fixed or is WONTFIX? I'm a bit confused...
> 
> I have submitted an update for Fedora 26, see comment 21.

I've installed the packages from koji (both x86_64, i686) and it seem to work just fine under Borderlands 2.

Thanks!

- Gilboa

Comment 27 Fedora Update System 2017-08-19 18:52:51 UTC
glibc-2.25-8.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-92f8958310

Comment 28 Fedora Update System 2017-08-20 18:28:39 UTC
glibc-2.25-8.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.

Comment 29 Dominik 'Rathann' Mierzejewski 2017-08-23 08:02:22 UTC
It seems to have fixed zsnes crash as well.