NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.06k stars 14.08k forks source link

Build failure: python312Packages.pymupdf @ 1.24.10 on Darwin #350072

Open sarahec opened 2 weeks ago

sarahec commented 2 weeks ago

Steps To Reproduce

Steps to reproduce the behavior:

  1. On Darwin, nix-build -A python312Packages.pymupdf
  2. Observe: the checkimports step fails (pymupdf fitz)

This failure does not happen on Linux-x86_64.

Build log

       > Executing pythonImportsCheckPhase
       > Check whether the following modules can be imported: pymupdf fitz
       > /nix/store/f0nb70gf98frbdpmc3vgdlqh6cp0k0a9-python-imports-check-hook.sh/nix-support/setup-hook: line 15: 25083 Killed: 9               /nix/store/ybnf7k6i9p244bbhsbxizqk65z58cwyr-python3-3.12.6/bin/python3.12 -c 'import os; import importlib; list(map(lambda mod: importlib.import_module(mod), os.environ["pythonImportsCheck"].split()))'

Additional context

The failure happens for both pymupdf and fitz -- commenting each one out individually still triggered the error.

Notify maintainers

@teto @emilazy for Darwin

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"aarch64-darwin"`
 - host os: `Darwin 24.0.0, macOS 15.0.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.18.5`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs````

Add a :+1: reaction to issues you find important.

elohmeier commented 4 days ago

This issue happens due to pymupdf loading the tesseract library which is not codesigned.

This can be seen in the crash report in macOS Console.App:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               python3.12 [28717]
Path:                  /Volumes/VOLUME/*/python3.12
Identifier:            python3.12
Version:               ???
Code Type:             ARM-64 (Native)
Parent Process:        fish [14635]
Responsible:           iTerm2 [11013]
User ID:               502

Date/Time:             2024-11-01 05:23:33.0894 +0100
OS Version:            macOS 15.0.1 (24A348)
Report Version:        12

Time Awake Since Boot: 1000000 seconds
Time Since Wake:       1038260 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGKILL (Code Signature Invalid))
Exception Codes:       UNKNOWN_0x32 at 0x0000000102690000
Exception Codes:       0x0000000000000032, 0x0000000102690000

Termination Reason:    Namespace CODESIGNING, Code 2 Invalid Page

VM Region Info: 0x102690000 is in 0x102690000-0x1028c0000;  bytes after start: 0  bytes before end: 2293759
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      mapped file                 10235c000-102690000    [ 3280K] r--/rwx SM=COW  Object_id=ef68854c
--->  mapped file                 102690000-1028c0000    [ 2240K] r-x/rwx SM=COW  Object_id=ef68854c
      VM_ALLOCATE (reserved)      1028c0000-1029c4000    [ 1040K] rw-/rwx SM=NUL  reserved VM address space (unallocated)
[...]

The last file accessed before loading pymupdf (via sudo fs_usage -f filesys python3.12):

[...]
05:27:36  open              daajpvv-tesseract-5.3.4/lib/libtesseract.5.dylib    0.000021   python3.12
05:27:36  fcntl                                                                 0.000001   python3.12
05:27:36  close                                                                 0.000001   python3.12
05:27:36  stat64            daajpvv-tesseract-5.3.4/lib/libtesseract.5.dylib    0.000002   python3.12
05:27:36  stat64            daajpvv-tesseract-5.3.4/lib/libtesseract.5.dylib    0.000002   python3.12
05:27:36  open              daajpvv-tesseract-5.3.4/lib/libtesseract.5.dylib    0.000009   python3.12
05:27:36  fcntl                                                                 0.000001   python3.12
05:27:36  close                                                                 0.000001   python3.12
05:27:36  exit                                                                  0.000018   python3.12

I'm pushing a PR to fix the underlying tesseract issue in a minute.