rattler-build icon indicating copy to clipboard operation
rattler-build copied to clipboard

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

Open DerThorsten opened this issue 1 year ago • 5 comments

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)

DerThorsten avatar Aug 01 '24 07:08 DerThorsten

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.

wolfv avatar Aug 01 '24 08:08 wolfv

I also experienced this problem. Beside the patch parser being more strict, there is any trick for how to make a patch compatible with the existing rattler-build patch parser if one is experiencing this problem?

traversaro avatar Dec 30 '24 22:12 traversaro

For reference, the output in my case is:

 ╭─ Running build for recipe: ros-humble-iceoryx-hoofs-2.0.5-np126py311h7d8ee0e_8
 │
 │ ╭─ Fetching source code
 │ │ Fetching source from git repo: https://github.com/ros2-gbp/iceoryx-release.git
 │ │ Fetching repository from https://github.com/ros2-gbp/iceoryx-release.git at refs/tags/release/humble/iceoryx_hoofs/2.0.5-1 into D:\src\ros-humble\output\src_cache\ice
 │ │ oryx-release.git
HEAD is now at a0edde7 Trimmed the branch to only the iceoryx_hoofs sub directory
 │ │ Checked out revision: 'refs/tags/release/humble/iceoryx_hoofs/2.0.5-1' at 'a0edde7d68649631be7d42b81ec9ddbabf2c011a'
 │ │ Copied 486 files into isolated environment
thread 'main' panicked at D:\bld\rattler-build_1734955589425\_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: ' include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
-list(APPEND CMAKE_MODULE_PATH "@DESTINATION_CONFIGDIR@")
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
 check_required_components("@PROJECT_NAME@")
'
stack backtrace:
   0:     0x7ff6ce7abcad - <unknown>
   1:     0x7ff6ce7d3899 - <unknown>
   2:     0x7ff6ce7a5ff1 - <unknown>
   3:     0x7ff6ce7adfa7 - <unknown>
   4:     0x7ff6ce7adb99 - <unknown>
   5:     0x7ff6ce7ae6e2 - <unknown>
   6:     0x7ff6ce7ae526 - <unknown>
   7:     0x7ff6ce7ac61f - <unknown>
   8:     0x7ff6ce7ae106 - <unknown>
   9:     0x7ff6ce91bea4 - <unknown>
  10:     0x7ff6cde378a5 - <unknown>
  11:     0x7ff6cde353cd - <unknown>
  12:     0x7ff6cd917c02 - <unknown>
  13:     0x7ff6cd505043 - <unknown>
  14:     0x7ff6cd50da87 - <unknown>
  15:     0x7ff6cd4deba2 - <unknown>
  16:     0x7ff6cd16b214 - <unknown>
  17:     0x7ff6cd1e2153 - <unknown>
  18:     0x7ff6cd1f4da6 - <unknown>
  19:     0x7ff6cd38c77c - <unknown>
  20:     0x7ff6cd2fe79b - <unknown>
  21:     0x7ff6cd410292 - <unknown>
  22:     0x7ff6cd3df5a6 - <unknown>
  23:     0x7ff6cd3df4fa - <unknown>
  24:     0x7ff6ce79c3b9 - <unknown>
  25:     0x7ff6cd41058c - <unknown>
  26:     0x7ff6ce88394c - <unknown>
  27:     0x7ffbe02a259d - BaseThreadInitThunk
  28:     0x7ffbe136af38 - RtlUserThreadStart
 │ │
 │ ╰─────────────────── (took 2 seconds)
 │
 ╰─────────────────── (took 2 seconds)

and I was trying to backport the patch from https://github.com/eclipse-iceoryx/iceoryx/pull/2231 .

traversaro avatar Dec 30 '24 22:12 traversaro

rattler-build has problems with these two patches too:

https://github.com/conda-forge/jxrlib-feedstock/blob/main/recipe/define_byteswap.patch https://github.com/conda-forge/jxrlib-feedstock/blob/main/recipe/usecmake.patch

DerThorsten avatar Feb 18 '25 08:02 DerThorsten

Also patches from the freeimage-feedstock fail.

DerThorsten avatar Feb 18 '25 13:02 DerThorsten

another example:

package:
  name: polars
  version: '1.29.0'

source:
  url: https://pypi.org/packages/source/p/polars/polars-1.29.0.tar.gz
  sha256: d2acb71fce1ff0ea76db5f648abd91a7a6c460fafabce9a2e8175184efa00d02
  patches:
    - my-patch.patch
diff --git a/Cargo.toml b/Cargo.toml
index eee839d352..9cb6ef11b7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -140,6 +140,7 @@ features = [
 # packed_simd_2 = { git = "https://github.com/rust-lang/packed_simd", rev = "e57c7ba11386147e6d2cbad7c88f376aab4bdc86" }
 # simd-json = { git = "https://github.com/ritchie46/simd-json", branch = "alignment" }
 tikv-jemallocator = { git = "https://github.com/pola-rs/jemallocator", rev = "c7991e5bb6b3e9f79db6b0f48dcda67c5c3d2936" }
+argminmax = { path = "./argminmax" }

 [profile.mindebug-dev]
 inherits = "dev"

pavelzw avatar May 06 '25 20:05 pavelzw

Fixed by #1641

wolfv avatar May 11 '25 10:05 wolfv