Skip to content

wrapQtAppsHook: wrap binaries in libexec - #64720

Merged
worldofpeace merged 4 commits into
NixOS:masterfrom
worldofpeace:wrapqt-libexec
Jul 19, 2019
Merged

worldofpeace merged 4 commits into
NixOS:masterfrom
worldofpeace:wrapqt-libexec

Conversation

@worldofpeace

Copy link
Copy Markdown
Contributor
Motivation for this change

See feedback at #54525 (comment).
This should be fine to do, it's already done in wrapGAppsHook.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@worldofpeace

Copy link
Copy Markdown
Contributor Author

I've noticed with wrapGAppsHook that if there's binaries at sbin that they don't get wrapped.
I'm thinking this was because move-sbin fixupOutputHooks came after wrapGAppsHook so they don't get touched.

Mentioning because I'd think wrapQtAppsHook could inherit that issue.

@ofborg ofborg Bot added 6.topic: qt/kde Object-oriented framework for GUI creation 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 501-1000 This PR causes many rebuilds on Linux and should normally target the staging branches. labels Jul 14, 2019
@ttuegel

ttuegel commented Jul 15, 2019

Copy link
Copy Markdown
Member

What happens when a bin/ executable execs a libexec/ executable? Won't the environment grow?

@worldofpeace

Copy link
Copy Markdown
Contributor Author

What happens when a bin/ executable execs a libexec/ executable? Won't the environment grow?

Yes, environment variables are going to propagate to child processes and often they can be wrapped too.
So this leakage can be problematic, but it's a known drawback to this approach.

@coreyoconnor

Copy link
Copy Markdown
Contributor

LGTM. This resolved the activitymanagerd failure I noted in #54525 (comment)

However, the plasma 5 test is still failing. A different failure. Does not appear to be a regression caused by this change. Log:

Not clear to me what failed this time.

@worldofpeace

Copy link
Copy Markdown
Contributor Author

LGTM. This resolved the activitymanagerd failure I noted in #54525 (comment)

However, the plasma 5 test is still failing. A different failure. Does not appear to be a regression caused by this change. Log:

* https://gist.github.com/coreyoconnor/410e5291aebce30c611f68abcf448870

Not clear to me what failed this time.

Can you run the test interactively and debug from there?

nix-build nixos/tests/plasma5.nix -A driver 

@worldofpeace

worldofpeace commented Jul 16, 2019 •

Copy link
Copy Markdown
Contributor Author

Running the test interactively everything works for me
Screenshot from 2019-07-16 18 44 16

What the issue here is that the wrappers fuzzed the argv0 so the test needs to be adapted
* https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/plasma5.nix#L53

I'll include a commit for that here.

@worldofpeace

worldofpeace commented Jul 16, 2019 •

Copy link
Copy Markdown
Contributor Author

Ok, after inspecting dolphin it's not being wrapped so it gets that error at runtime...
Pretty confused by that.

@ttuegel I was also looking at the wrapper make for okular and it has these entries

export XDG_DATA_DIRS='/nix/store/i5s8firmgld1wc8b9fsbq8kivwv51lw2-cmake-3.14.5/share'${XDG_DATA_DIRS:+':'}$XDG_DATA_DIRS
export XDG_DATA_DIRS='/nix/store/01a3dppfi3rv03m8yx2nwxbkklggyzf9-pkg-config-0.29.2/share'${XDG_DATA_DIRS:+':'}$XDG_DATA_DIRS

I'm almost certain those dependencies shouldn't be collected for the wrapper.

This was preventing dolphin from being wrapped.
@worldofpeace

Copy link
Copy Markdown
Contributor Author

I've discovered that isQtApp wasn't returning a non-zero exit status for dolphin's binaries.
Decided to just remove it 4908d38

@ofborg ofborg Bot added the 6.topic: emacs Text editor label Jul 17, 2019
@ofborg ofborg Bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. and removed 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 501-1000 This PR causes many rebuilds on Linux and should normally target the staging branches. labels Jul 17, 2019
@samueldr
samueldr requested a review from ttuegel July 17, 2019 02:48
@worldofpeace

Copy link
Copy Markdown
Contributor Author

So the NixOS test now "passes", but I'm seeing errors in the output like

QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-alice'

among others that somehow get drawn to the desktop after I run it interactively
Screenshot from 2019-07-16 23 03 13

@ofborg ofborg Bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 501-1000 This PR causes many rebuilds on Linux and should normally target the staging branches. and removed 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Jul 17, 2019
@coreyoconnor

Copy link
Copy Markdown
Contributor

Thanks! I can confirm the test passes. I haven't tried running the driver interactively. If I get a chance I'll try it and see.

@FRidh

FRidh commented Jul 17, 2019

Copy link
Copy Markdown
Member

@worldofpeace please remove the WIP label when it's not applicable.

@worldofpeace

Copy link
Copy Markdown
Contributor Author

@ttuegel Was isQtApp meant to prevent scripts from being wrapped?

I'm thinking that the new issues I'm seeing are because of that happening.
Though it's still possible that a script could need to be wrapped with $XDG* variables.

@ttuegel

ttuegel commented Jul 17, 2019

Copy link
Copy Markdown
Member

@worldofpeace isQtApp was intended to prevent wrapping scripts and non-GUI binaries that may not even depend on Qt. If it's causing problems, then remove it.

We should still prevent things like
scripts from being wrapped.
@worldofpeace

Copy link
Copy Markdown
Contributor Author

So with the latest commit, plasma5 test succeeds for me locally and interactively nothing seems wrong with the session.

I'm going to merge this to master so the channels can get unblocked.

@worldofpeace
worldofpeace merged commit 4c8eaa3 into NixOS:master Jul 19, 2019
@worldofpeace
worldofpeace deleted the wrapqt-libexec branch July 19, 2019 20:28
@FRidh

FRidh commented Jul 25, 2019

Copy link
Copy Markdown
Member

7d6ab0a breaks Python scripts that use Qt5 because they don't get wrapped because of the isELF check.

@coreyoconnor

Copy link
Copy Markdown
Contributor

I have patches in my nixpkgs that may impact this. Adding the issue I'm encountering here just in case it's actually related to this change. Plus, takes a while to build a variation. ;)

Some QT apps, for instance QGIS and OpenSCAD, encounter an infinite recursion that has a stack trace like so:

#0  0x000015554e001680 in QWindow::flags() const () from /nix/store/v4s0nq286hxwjms4k1sd378n597l3rka-qtbase-5.12.3/lib/libQt5Gui.so.5
#1  0x000015554e0016b9 in QWindow::type() const () from /nix/store/v4s0nq286hxwjms4k1sd378n597l3rka-qtbase-5.12.3/lib/libQt5Gui.so.5
#2  0x000015553e630c61 in ?? () from /nix/store/35855h0lfnpr21xbs48kd1ianwzzw0yv-qtbase-5.12.0-bin/lib/qt-5.12/plugins/xcbglintegrations/libqxcb-glx-integration.so
#3  0x000015554e001682 in QWindow::flags() const () from /nix/store/v4s0nq286hxwjms4k1sd378n597l3rka-qtbase-5.12.3/lib/libQt5Gui.so.5
#4  0x000015554e0016b9 in QWindow::type() const () from /nix/store/v4s0nq286hxwjms4k1sd378n597l3rka-qtbase-5.12.3/lib/libQt5Gui.so.5
#5  0x000015553e630c61 in ?? () from /nix/store/35855h0lfnpr21xbs48kd1ianwzzw0yv-qtbase-5.12.0-bin/lib/qt-5.12/plugins/xcbglintegrations/libqxcb-glx-integration.so
#6  0x000015554e001682 in QWindow::flags() const () from /nix/store/v4s0nq286hxwjms4k1sd378n597l3rka-qtbase-5.12.3/lib/libQt5Gui.so.5
#7  0x000015554e0016b9 in QWindow::type() const () from /nix/store/v4s0nq286hxwjms4k1sd378n597l3rka-qtbase-5.12.3/lib/libQt5Gui.so.5
#8  0x000015553e630c61 in ?? () from /nix/store/35855h0lfnpr21xbs48kd1ianwzzw0yv-qtbase-5.12.0-bin/lib/qt-5.12/plugins/xcbglintegrations/libqxcb-glx-integration.so

Note the libqxcb-glx-integration library.

(This is the issue I mentioned running qt apps in #63829 .)

@coreyoconnor

Copy link
Copy Markdown
Contributor

I have patches in my nixpkgs that may impact this. Adding the issue I'm encountering here just in case it's actually related to this change. Plus, takes a while to build a variation. ;)

I've reverted to nixos-unstable plus a few necessary patches and am not able to reproduce the above issue. I'll be adding back in QT PRs to see if they repro the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: qt/kde Object-oriented framework for GUI creation 8.has: clean-up This PR removes packages or removes other cruft 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 501-1000 This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants