prefix-dev / rattler-build

rattler-build is a universal package builder for Windows, macOS and Linux
https://prefix-dev.github.io/rattler-build
BSD 3-Clause "New" or "Revised" License
211 stars 45 forks source link

rattler-build panicked when trying to parse a certain patch. #1000

Open DerThorsten opened 3 months ago

DerThorsten commented 3 months ago

First observed here

When trying to build a package with this patch we get the following backtrace

rattler-build build --package-format tar-bz2 -c https://repo.mamba.pm/emscripten-forge -c microsoft -c conda-forge --target-platform emscripten-wasm32 --skip-existing all -m conda_build_config.yaml --recipe recipes/recipes_emscripten/bzip2

 ╭─ Finding outputs from recipe
 │ Found 1 variants
 │ Build variant: bzip2-1.0.8-hea785b7_7
 │
 │ ╭────────────────────┬───────────────────╮
 │ │ Variant            ┆ Version           │
 │ ╞════════════════════╪═══════════════════╡
 │ │ c_compiler         ┆ emscripten        │
 │ │ c_compiler_version ┆ 3.1.58            │
 │ │ channel_targets    ┆ conda-forge main  │
 │ │ cmake              ┆ 3.26.4            │
 │ │ target_platform    ┆ emscripten-wasm32 │
 │ ╰────────────────────┴───────────────────╯
 │
 ╰─────────────────── (took 0 seconds)

 ╭─ Checking existing builds
 │
 ╰─────────────────── (took 0 seconds)

 ╭─ Running build for recipe: bzip2-1.0.8-hea785b7_7
 │
 │ ╭─ Fetching source code
 │ │ Validated SHA256 values of the downloaded file!
 │ │ Found valid source cache file.
 │ │ Using extracted directory from cache: "/Users/thorstenbeier/src/recipes/output/src_cache/bzip2-1_0_8_ab5a0317"
 │ │ Copying source from url: "/Users/thorstenbeier/src/recipes/output/src_cache/bzip2-1_0_8_ab5a0317" to "/Users/thorstenbeier/src/recipes/output/bld/rattler-build_bzip2_1722497997/work"
thread 'main' panicked at /Users/runner/miniforge3/conda-bld/rattler-build_1721982004483/_build_env/.cargo/registry/src/index.crates.io-6f17d22bba15001f/patch-0.7.0/src/parser.rs:84:5:
bug: failed to parse entire input. Remaining: '# To assist in cross-compiling
-CC=gcc
-AR=ar
-RANLIB=ranlib
-LDFLAGS=
+CC?=gcc
+AR?=ar
+RANLIB?=ranlib

 BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
+CFLAGS?=-Wall -Winline -O2 -g
+CFLAGS=$(CFLAGS) $(BIGFILES)

# Where you want it installed when you do 'make install'
-PREFIX=/usr/local
+PREFIX=$PREFIX

 OBJS= blocksort.o  \
diff --git a/Makefile-libbz2_so b/Makefile-libbz2_so
index e58791b..f4b9fa2 100644
--- a/Makefile-libbz2_so
+++ b/Makefile-libbz2_so
@@ -22,9 +22,18 @@

 SHELL=/bin/sh
-CC=gcc
+
+# To assist in cross-compiling
+CC?=gcc
+AR?=ar
+RANLIB?=ranlib
+
 BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
+CFLAGS?=-Wall -Winline -O2 -g
+CFLAGS=$(CFLAGS) $(BIGFILES)
+
+# Where you want it installed when you do 'make install'
+PREFIX=$PREFIX

 OBJS= blocksort.o  \
       huffman.o    \

'
stack backtrace:
   0:        0x103ea096c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1f3776e0b5c7517d
   1:        0x103ec4c88 - core::fmt::write::heedef092c8c0962e
   2:        0x103e9c2c4 - std::io::Write::write_fmt::h7178e8e2ea928914
   3:        0x103ea07c4 - std::sys_common::backtrace::print::h417292deb95532ed
   4:        0x103ea1b44 - std::panicking::default_hook::{{closure}}::h0cb68f1228c4613a
   5:        0x103ea1838 - std::panicking::default_hook::h24535936bc1f51de
   6:        0x103ea23fc - std::panicking::rust_panic_with_hook::h5db4d2345b297bed
   7:        0x103ea1e2c - std::panicking::begin_panic_handler::{{closure}}::h3fd558f09a0d5492
   8:        0x103ea0df4 - std::sys_common::backtrace::__rust_end_short_backtrace::hfc76eebe1ce501b2
   9:        0x103ea1b9c - _rust_begin_unwind
  10:        0x103f5bbc0 - core::panicking::panic_fmt::hc2b459a5bd3dce66
  11:        0x103784e28 - patch::parser::parse_multiple_patches::h7a3c0f9ee630e0a0
  12:        0x103351c00 - rattler_build::source::patch::apply_patches::h3838e452322bb7af
  13:        0x1030f0e64 - rattler_build::source::fetch_sources::{{closure}}::h0f6c581cc7c63fd4
  14:        0x1030de59c - rattler_build::build::run_build::{{closure}}::h196bc9372f2a9e21
  15:        0x102eceb64 - rattler_build::main::{{closure}}::h10a71dda4a3811a1
  16:        0x102ec3ccc - tokio::runtime::park::CachedParkThread::block_on::h1bf6c622e6a9e257
  17:        0x1030199b0 - tokio::runtime::runtime::Runtime::block_on::h722ee0da1d3f4358
  18:        0x102f515d8 - rattler_build::main::hf9047b687fcc7d33
  19:        0x1030f5dd4 - std::sys_common::backtrace::__rust_begin_short_backtrace::hf693ea9d9a0d9fef
  20:        0x102fde5c4 - std::rt::lang_start::{{closure}}::hca3202f9fe2a28e7
  21:        0x103e93a70 - std::rt::lang_start_internal::hecc68fef83c8f44d
  22:        0x102f517e8 - _main
 │ │
 │ ╰─────────────────── (took 0 seconds)
 │
 ╰─────────────────── (took 0 seconds)
wolfv commented 3 months ago

Thanks for filing the bug! Our patch parser is, unfortunately, more strict than some patches that are found in the wild. I think we'll have to fork it and make it a bit more lenient.