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

Mixing package sources caues segfaults when running cli tools with python's subprocess.run #1469

Open
Enteee opened this issue Sep 24, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@Enteee
Copy link

Enteee commented Sep 24, 2024

Describe the bug

When mixing package sources (devenv pkgs and nixpkgs-stable) the following test fails:

To reproduce

For the configuration below, run devenv test.

devenv.nix:

{ pkgs, lib, config, inputs, ... }:

let
  pkgs-stable = import inputs.nixpkgs-stable {
    system = pkgs.stdenv.system;
    config = pkgs.config;
  };
in
{

  # does segfault
  packages = [ pkgs-stable.coreutils ];

  # does not segfault:
  # packages = [ pkgs.coreutils ];

  languages.python.enable = true;

  enterTest = ''
    echo "Running tests"
    python -c 'from subprocess import run; run("uname", check=True)'
  '';
}

devenv.yml

# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
inputs:
  nixpkgs:
    url: github:cachix/devenv-nixpkgs/rolling
  nixpkgs-stable:
    url: github:NixOS/nixpkgs/nixos-24.05

devenv.lock

{
  "nodes": {
    "devenv": {
      "locked": {
        "dir": "src/modules",
        "lastModified": 1727183374,
        "owner": "cachix",
        "repo": "devenv",
        "rev": "e3f0b77d6c40b28f1bb3411387e314934092ec8e",
        "type": "github"
      },
      "original": {
        "dir": "src/modules",
        "owner": "cachix",
        "repo": "devenv",
        "type": "github"
      }
    },
    "flake-compat": {
      "flake": false,
      "locked": {
        "lastModified": 1696426674,
        "owner": "edolstra",
        "repo": "flake-compat",
        "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
        "type": "github"
      },
      "original": {
        "owner": "edolstra",
        "repo": "flake-compat",
        "type": "github"
      }
    },
    "gitignore": {
      "inputs": {
        "nixpkgs": [
          "pre-commit-hooks",
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1709087332,
        "owner": "hercules-ci",
        "repo": "gitignore.nix",
        "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
        "type": "github"
      },
      "original": {
        "owner": "hercules-ci",
        "repo": "gitignore.nix",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1716977621,
        "owner": "cachix",
        "repo": "devenv-nixpkgs",
        "rev": "4267e705586473d3e5c8d50299e71503f16a6fb6",
        "type": "github"
      },
      "original": {
        "owner": "cachix",
        "ref": "rolling",
        "repo": "devenv-nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs-stable": {
      "locked": {
        "lastModified": 1726969270,
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "23cbb250f3bf4f516a2d0bf03c51a30900848075",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-24.05",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs-stable_2": {
      "locked": {
        "lastModified": 1726969270,
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "23cbb250f3bf4f516a2d0bf03c51a30900848075",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-24.05",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "pre-commit-hooks": {
      "inputs": {
        "flake-compat": "flake-compat",
        "gitignore": "gitignore",
        "nixpkgs": [
          "nixpkgs"
        ],
        "nixpkgs-stable": "nixpkgs-stable_2"
      },
      "locked": {
        "lastModified": 1726745158,
        "owner": "cachix",
        "repo": "pre-commit-hooks.nix",
        "rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74",
        "type": "github"
      },
      "original": {
        "owner": "cachix",
        "repo": "pre-commit-hooks.nix",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "devenv": "devenv",
        "nixpkgs": "nixpkgs",
        "nixpkgs-stable": "nixpkgs-stable",
        "pre-commit-hooks": "pre-commit-hooks"
      }
    }
  },
  "root": "root",
  "version": 7
}

Make sure to include full logs and what you expected to happen.

Version

devenv 1.1.0 (x86_64-linux)

@Enteee Enteee added the bug Something isn't working label Sep 24, 2024
@Enteee
Copy link
Author

Enteee commented Sep 24, 2024

I tried debugging this a bit and seems like the segfault happens in:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x000070154334af69 in gettimeofday () from /nix/store/7v7c61ikm7cbd3kbimk9qr8h7pdmyccn-manylinux2014/lib/libc.so.6
#2  0x0000701543539c34 in _dl_relocate_object () from /nix/store/r8qsxm85rlxzdac7988psm7gimg4dl3q-glibc-2.39-52/lib/ld-linux-x86-64.so.2
#3  0x0000701543549d69 in dl_main () from /nix/store/r8qsxm85rlxzdac7988psm7gimg4dl3q-glibc-2.39-52/lib/ld-linux-x86-64.so.2
#4  0x00007015435465f3 in _dl_sysdep_start () from /nix/store/r8qsxm85rlxzdac7988psm7gimg4dl3q-glibc-2.39-52/lib/ld-linux-x86-64.so.2
#5  0x0000701543547d8e in _dl_start () from /nix/store/r8qsxm85rlxzdac7988psm7gimg4dl3q-glibc-2.39-52/lib/ld-linux-x86-64.so.2
#6  0x0000701543546bd8 in _start () from /nix/store/r8qsxm85rlxzdac7988psm7gimg4dl3q-glibc-2.39-52/lib/ld-linux-x86-64.so.2
#7  0x0000000000000002 in ?? ()
#8  0x00007ffc3bfdf46f in ?? ()
#9  0x00007ffc3bfdf475 in ?? ()
#10 0x0000000000000000 in ?? ()

@Enteee
Copy link
Author

Enteee commented Sep 24, 2024

If i add pkgs-stable.coreutils to the packages = [ .. ] array poetry install starts failing with segfaults in uname :)

@domenkozar
Copy link
Member

languages.python.manylinux.enable = false;

@Enteee
Copy link
Author

Enteee commented Sep 25, 2024

Thank you @domenkozar.

Yes, this solves it. But I don't really understand why...
How does disabling a layer that should improve compatibility actually makes my python env more compatible with different versions of packages?

@Enteee
Copy link
Author

Enteee commented Sep 25, 2024

Thank you @domenkozar.

Yes, this solves it. But I don't really understand why... How does disabling a layer that should improve compatibility actually makes my python env more compatible with different versions of packages?

mhmm.. actually no. Looks like i am still seeing this issue when I am trying to run a cli in a test with pytest. Let my try to derive a new minimal failing example.

@Enteee
Copy link
Author

Enteee commented Sep 25, 2024

ok.. i was struggling quite a bit trying to reproduce this in a minimal example. But I could easily reproduce this issue in my project. I tried copying over all lock files and making my minimal example very similar to my project.

Turns out after I rm -rf .venv in my project - I can no longer reproduce this in my project either..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants