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

wrapQtAppsHook: wrap binaries in libexec #64720

Merged
merged 4 commits into from Jul 19, 2019

Conversation

worldofpeace
Copy link
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
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.

@ttuegel
Copy link
Member

ttuegel commented Jul 15, 2019

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

@worldofpeace
Copy link
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
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
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
Copy link
Contributor Author

worldofpeace commented Jul 16, 2019

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
Copy link
Contributor Author

worldofpeace commented Jul 16, 2019

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
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

@worldofpeace
Copy link
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

@coreyoconnor
Copy link
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
Copy link
Member

FRidh commented Jul 17, 2019

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

@worldofpeace
Copy link
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
Copy link
Member

ttuegel commented Jul 17, 2019

@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
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
Copy link
Member

FRidh commented Jul 25, 2019

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

@coreyoconnor
Copy link
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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants