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

rust: fails on clang32 #9091

Closed
jeremyd2019 opened this issue Jul 4, 2021 · 46 comments · Fixed by #14036
Closed

rust: fails on clang32 #9091

jeremyd2019 opened this issue Jul 4, 2021 · 46 comments · Fixed by #14036
Labels

Comments

@jeremyd2019
Copy link
Member

    = note: lld-link: error: undefined symbol: @rust_psm_on_stack@16
            >>> referenced by libpsm-a103c78323d6f2a6.rlib(x86_windows_gnu.o)

Oddly,
https://github.com/rust-lang/stacker/blob/master/psm/src/arch/x86_windows_gnu.s#L63-L69

.def @rust_psm_on_stack@16
.scl 2
.type 32
.endef
.globl @rust_psm_on_stack@16
.p2align 4
@rust_psm_on_stack@20:

What's up with that @20 ? Maybe that's the cause?

@jeremyd2019
Copy link
Member Author

I tried patching this, but the error still occurs.

@jeremyd2019
Copy link
Member Author

very strange, the .o and .a still have the @20 symbol

@jeremyd2019
Copy link
Member Author

@mati865 ? I don't even know where 'upstream' is for that file to report or send a pull request, nor do I know why patching the @20 out of the source file and I still end up having binaries with @20 in them.

@jeremyd2019
Copy link
Member Author

jeremyd2019 commented Jul 5, 2021

I've discovered --enable-vendor - might have a chance then patching the file in vendor/. Had to update cc from 1.0.65 to 1.0.67 cause the vendor stuff only had 1.0.60 or 1.0.67.

D'oh

error: the listed checksum of `T:\mingw-w64-rust\src\rustc-1.53.0-src\vendor\psm\src/arch/x86_windows_gnu.s` has changed:
expected: 9f2e4fc442841e88b5868afb45453515c583d2384d7b3e73605130aa929d0807
actual:   4caa0cf35bf6487f4a2a23764120b86ff5d29362125902ab7720c7258cf1741e

directory sources are not intended to be edited, if modifications are required then it is recommended that [replace] is used with a forked copy of the source

@jeremyd2019
Copy link
Member Author

rust-lang/stacker#54

@jeremyd2019
Copy link
Member Author

This seems to be working. Will try to make a PR (draft cause it's pretty clear that rust doesn't want you to patch their vendored code)

@jeremyd2019
Copy link
Member Author

Eventually got this error:

error: failed to run custom build command for `html5ever v0.25.1`

Caused by:
  process didn't exit successfully: `T:\mingw-w64-rust\src\i686\build\i686-pc-windows-gnu\stage0-bootstrap-tools\release\build\html5ever-7b859b6107fbb733\build-script-build` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)
  --- stdout
  cargo:rerun-if-changed=T:\mingw-w64-rust\src\rustc-1.53.0-src\vendor\html5ever\src/tree_builder/rules.rs

  --- stderr
  fatal runtime error: failed to initiate panic, error 5

@jeremyd2019
Copy link
Member Author

rust-lang/stacker#54

This was merged and Published as 0.1.14

jeremyd2019 added a commit that referenced this issue Jul 7, 2021
All packages which successfully built on clang64, for which all of their
dependencies are already available for clang32.  Except for rust
(#9091).

Batch 7
jeremyd2019 added a commit that referenced this issue Jul 18, 2021
All packages which successfully built on clang64, for which all of their
dependencies are already available for clang32.  Except for rust
(#9091).

Batch 8
@mati865
Copy link
Collaborator

mati865 commented Jul 23, 2021

I hacked source code (by disabling what fails to build) and it passed the build but the compiler is totally broken.

@mati865
Copy link
Collaborator

mati865 commented Sep 5, 2021

I've tried aborting instead of unwinding but this doesn't help. Seems we need proper unwinding because code that runs proc-macros relies on catching the exceptions.
What I believe the issue with unwinding is: https://github.com/llvm/llvm-project/blob/f5b997e6b7061323fff13fafcc0c311d9e78e848/libunwind/src/UnwindLevel1-gcc-ext.c#L272

@jeremyd2019
Copy link
Member Author

Did some debugging. Somehow the .eh_frame unwinding information for (statically-linked) libunwind.a is not found. This causes unwinding to fail in the first stack frame, which is _Unwind_RaiseException where _unw_getcontext is called (https://github.com/llvm/llvm-project/blob/f5b997e6b7061323fff13fafcc0c311d9e78e848/libunwind/src/UnwindLevel1.c#L401)

@jeremyd2019
Copy link
Member Author

For reference, the .eh_frame data for libunwind is present when statically-linking a C++ program.

In my test program, the return address from the call to __unw_getcontext is 0x00f8548f, the exe is loaded at 0x00f80000, so the RVA is 0x548f. Looking at llvm-dwarfdump --eh-frame testexc.exe for a pc range that contains that RVA:

000016a0 0000001c 0000001c FDE cie=00001688 pc=00405450...004056c8
  Format:       DWARF32
  DW_CFA_advance_loc: 1
  DW_CFA_def_cfa_offset: +8
  DW_CFA_offset: EBP -8
  DW_CFA_advance_loc: 2
  DW_CFA_def_cfa_register: EBP
  DW_CFA_advance_loc: 12
  DW_CFA_offset: ESI -20
  DW_CFA_offset: EDI -16
  DW_CFA_offset: EBX -12

@jeremyd2019
Copy link
Member Author

For a test, I am hacking the libgcc hack and clang subsystem patch to always use dynamic libunwind

@jeremyd2019
Copy link
Member Author

That gets it a stack frame further into unwinding but then can't find unwind info for https://github.com/rust-lang/rust/blob/1cf8fdd4f0be26bcfa9e3b1e10d4bf80107ba492/library/panic_unwind/src/gcc.rs#L62 I guess there's something wrong with the writing of .eh_frame when linking (the correct info was present in libunwind.a, but once it was linked into an exe it was missing).

@jeremyd2019
Copy link
Member Author

Kind of feels like https://reviews.llvm.org/D84607, but when trying to look via objdump -x there don't seem to be any .eh_frame$ sections, just .eh_frame. Going to try now with function sections turned off.

@jeremyd2019
Copy link
Member Author

That didn't help. @mstorsjo hate to ping you on such a meandering thread, but do you know any way to figure out why .eh_frame FDEs might be missing in the link output, and/or how to extract an LLD reproducer from a rust build?

@jeremyd2019
Copy link
Member Author

I think I found how to output linker command line, and add an option to linker, for rust build.

@jeremyd2019
Copy link
Member Author

jeremyd2019 commented Sep 21, 2021

Turns out RUSTFLAGS don't seem to apply to 'host' tools, which is what is failing. I have not yet seen anything like HOSTRUSTFLAGS. https://github.com/rust-lang/cargo/blob/18751dd3f238d94d384a7fe967abfac06cbfe0b9/src/cargo/core/compiler/build_context/target_info.rs#L589-L613

@jeremyd2019
Copy link
Member Author

I was hoping to get a repro.tar from lld, but not being able to add flags to the 'build script' build (and it apparently cleaning up its .o files) is making that not possible. It appears that .eh_frame info is missing though. I was able to get the linker command line, and it is passing -Wl,--gc-sections, so that may be part of it.

INFO rustc_codegen_ssa::back::link "i686-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-Wl,--large-address-aware" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\rsbegin.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.0.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.1.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.10.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.11.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.12.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.13.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.14.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.15.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.2.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.3.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.4.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.5.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.6.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.7.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.8.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.build_script_build.ckqhkxgx-cgu.9.rcgu.o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.2873gyi7qo0kquja.rcgu.o" "-L" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps" "-L" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib" "-Wl,-Bstatic" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libserde_json-8f79abc662d46c99.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libryu-3f0c5d6f1452a2d9.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libitoa-7a4d06f4f3da8c68.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libserde-01995d291cbc84cc.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libstring_cache_codegen-37e2cde66d4d2018.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libquote-4f85d09b6680abe5.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libproc_macro2-93c870a44d492a16.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libunicode_xid-9730d74bbcbc005a.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libproc_macro-364d37782a449056.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libphf_codegen-9ea5147427079124.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libphf_generator-1bf391c8c7e87959.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\librand-3a2fde4a1a98630d.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\librand_pcg-abd2f284dad7b744.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\librand_chacha-7b7f501e5882adf7.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libppv_lite86-8a9c0e55ff5c4aa0.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\librand_core-c4ece68bf1f561e4.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libgetrandom-39648d2fbcafed2c.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libcfg_if-88cb815f574c7f53.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libphf_shared-f4d0516a88c9ce4e.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\deps\\libsiphasher-b197227a354f2b2a.rlib" "-Wl,--start-group" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libstd-88bd6a69b9765a29.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libpanic_unwind-a5326e6a202b17db.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libobject-6cd7951ed5ffd74c.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libaddr2line-901bf2c4ae359754.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libgimli-3677d4c793bbcbb3.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libstd_detect-95bd99907f9a5c49.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\librustc_demangle-0667d0563a407819.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libhashbrown-fda26d6f83bc1911.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-2b9ff6554685a2a0.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libunwind-6b665701c97a10f9.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libcfg_if-e5fbf340eee3de7b.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\liblibc-f4532885ee407885.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\liballoc-e28ee0a3f65c2ca6.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\librustc_std_workspace_core-4c01307ead46b7cc.rlib" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libcore-536fab33d0499cb5.rlib" "-Wl,--end-group" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libcompiler_builtins-3924670c628e82f0.rlib" "-Wl,-Bdynamic" "-ladvapi32" "-lkernel32" "-lws2_32" "-ladvapi32" "-luserenv" "-lkernel32" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib" "-o" "T:\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0-bootstrap-tools\\release\\build\\markup5ever-799f2c76071bbe80\\build_script_build-799f2c76071bbe80.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "C:\\msys64\\home\\adminuser\\MINGW-packages\\mingw-w64-rust\\src\\i686\\build\\i686-pc-windows-gnu\\stage0\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\rsend.o"

@mati865
Copy link
Collaborator

mati865 commented Jan 29, 2022

There is some oddity in llvm-nm:

$ /clang64/bin/nm /d/tmp/r/src/CLANG32/build/i686-pc-windows-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib/rsbegin.o | grep eh_frame
00000000 R __ZN7rsbegin9eh_frames10mingw_init6P_INIT17hcac2d6c918db7f49E
00000000 R __ZN7rsbegin9eh_frames10mingw_init8P_UNINIT17h565e94d416ee6b01E
00000000 b __ZN7rsbegin9eh_frames3OBJ17hc37ee6dbaafc1617E
00000000 T __ZN7rsbegin9eh_frames4init17h9df17b84a7f77d8bE
00000030 T __ZN7rsbegin9eh_frames6uninit17h82158f3bb655b85bE
00000004 D __imp___ZN7rsbegin9eh_frames10mingw_init6P_INIT17hcac2d6c918db7f49E
00000008 D __imp___ZN7rsbegin9eh_frames10mingw_init8P_UNINIT17h565e94d416ee6b01E

$ /mingw64/bin/nm /d/tmp/r/src/CLANG32/build/i686-pc-windows-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib/rsbegin.o | grep eh_frame
00000000 r .eh_frame
00000004 D __imp___ZN7rsbegin9eh_frames10mingw_init6P_INIT17hcac2d6c918db7f49E
00000008 D __imp___ZN7rsbegin9eh_frames10mingw_init8P_UNINIT17h565e94d416ee6b01E
00000000 R __ZN7rsbegin9eh_frames10mingw_init6P_INIT17hcac2d6c918db7f49E
00000000 R __ZN7rsbegin9eh_frames10mingw_init8P_UNINIT17h565e94d416ee6b01E
00000000 b __ZN7rsbegin9eh_frames3OBJ17hc37ee6dbaafc1617E
00000000 T __ZN7rsbegin9eh_frames4init17h9df17b84a7f77d8bE
00000030 T __ZN7rsbegin9eh_frames6uninit17h82158f3bb655b85bE

I have inspected crashing binary and it contains .eh_frame.

@mstorsjo
Copy link
Contributor

There is some oddity in llvm-nm:

$ /clang64/bin/nm /d/tmp/r/src/CLANG32/build/i686-pc-windows-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib/rsbegin.o | grep eh_frame
00000000 R __ZN7rsbegin9eh_frames10mingw_init6P_INIT17hcac2d6c918db7f49E
00000000 R __ZN7rsbegin9eh_frames10mingw_init8P_UNINIT17h565e94d416ee6b01E
00000000 b __ZN7rsbegin9eh_frames3OBJ17hc37ee6dbaafc1617E
00000000 T __ZN7rsbegin9eh_frames4init17h9df17b84a7f77d8bE
00000030 T __ZN7rsbegin9eh_frames6uninit17h82158f3bb655b85bE
00000004 D __imp___ZN7rsbegin9eh_frames10mingw_init6P_INIT17hcac2d6c918db7f49E
00000008 D __imp___ZN7rsbegin9eh_frames10mingw_init8P_UNINIT17h565e94d416ee6b01E

$ /mingw64/bin/nm /d/tmp/r/src/CLANG32/build/i686-pc-windows-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib/rsbegin.o | grep eh_frame
00000000 r .eh_frame
00000004 D __imp___ZN7rsbegin9eh_frames10mingw_init6P_INIT17hcac2d6c918db7f49E
00000008 D __imp___ZN7rsbegin9eh_frames10mingw_init8P_UNINIT17h565e94d416ee6b01E
00000000 R __ZN7rsbegin9eh_frames10mingw_init6P_INIT17hcac2d6c918db7f49E
00000000 R __ZN7rsbegin9eh_frames10mingw_init8P_UNINIT17h565e94d416ee6b01E
00000000 b __ZN7rsbegin9eh_frames3OBJ17hc37ee6dbaafc1617E
00000000 T __ZN7rsbegin9eh_frames4init17h9df17b84a7f77d8bE
00000030 T __ZN7rsbegin9eh_frames6uninit17h82158f3bb655b85bE

I have inspected crashing binary and it contains .eh_frame.

This difference probably is about whether there is a section symbol for the section or not. Technically, at the lowest level, those section symbols are pretty much unnecessary. I guess there is none, while gnu nm maybe does print one anyway (as there is a section still). Llvm’s obj2yaml tool is great for looking at all the contents of an object file to see what it really is.

As for the root cause, dwarf unwinding is kinda tricky. (Sorry I never commented on this earlier when I was pinged.) The main contents of the .eh_frame in object files is the same between all the toolchains - but they’re hooked up a bit differently between libgcc and Llvm’s libunwind.

With libgcc, there are marker symbols in crtbegin/crtend.o, named like __EH_FRAME_BEGIN__. On startup, there’s a call to __register_frame, which adds the range of contents between the two marker symbols to the known unwind info in libgcc.

With libunwind, there’s no such static registration, but when necessary, libunwind iterates over the loaded dlls/exes, and finds all the .eh_frame sections in them.

However, if the marker symbols are non-empty (I remember them being nonempty in libgcc’s crtbegin.o, even if it would seem empty when I try to read the source right now), libunwind would see 4 unexpected zero bytes (indicating a terminator of the section) at the start of the .eh_frame section, which iirc broke things once when I tried that.

A different possible failure mode is if the unwinder used does expect the data to be registered, but it isn’t, or if the section contents is outside of the markers, so it doesn’t get included.

At least libunwind has got some debug logging included that should be possible to turn on, which helps for getting at least some idea of what’s going on.

@mati865
Copy link
Collaborator

mati865 commented Feb 1, 2022

FWIW Rust has it's own CRT begin and end files: https://github.com/rust-lang/rust/tree/master/library/rtstartup and does not use those from C toolchain.

@jeremyd2019
Copy link
Member Author

jeremyd2019 commented Oct 2, 2022

Maybe someday we can get back to trying to figure this out... What I remember from debugging at the time was that unwind information for many functions were missing from .eh_frame section, even though those functions had unwind information in their original .a files (most notably, unwind information for functions in libunwind itself, which caused unwinding to fail on the very first function on the stack).

@jeremyd2019
Copy link
Member Author

Possibly coincidentally, ran into an unwinding issue trying to get rustc bootstrapped on arm64 (#13278 (comment)). Don't know if x86_64 is the odd man out and both i686 and aarch64 are plagued by some underlying unwinding issue, or if it's just a coincidence that both happened to fail in the unwinding code.

@mati865
Copy link
Collaborator

mati865 commented Oct 15, 2022

Small update:
Noticed the exceptions do work for rustc.exe but are broken for other tools like rustdoc.exe (at least with my local changes to Rust source code).
I've started CLion trial because I cannot use debuggers outside IDE and this is how it looks:
image
This is right before calling *p (highlighted line) which is going to segfault.
Going to get some sleep right now and I'll do more testing later.

@mstorsjo
Copy link
Contributor

Ok, great! So unwinding mostly works, but here, it hits a stack frame where something goes wrong. That changes what we need to look for.

Which function does this correspond to, and where does frameInfo.handler come from?

@mati865
Copy link
Collaborator

mati865 commented Oct 15, 2022

Unfortunately I couldn't find out what is under that failing address.
In all the good frames frameInfo.handler points to https://github.com/rust-lang/rust/blob/91f128baf7704a477ab7c499143a160fb069b3ad/library/std/src/personality/gcc.rs#L244 but for that one problematic frame neither GDB or LLDB can read the memory it points to. Also that address is always small like 0xbc0000, 0x8f0000 (varies between builds but that is expected).
All I know its being set in https://github.com/llvm/llvm-project/blob/8805e5d1b7be72b007448477aa55cc6b104b4842/libunwind/src/UnwindCursor.hpp#L2845 but I wasn't able to get any info from it as the details seem to be optimised out. That was with statically linked debug libunwind, gonna try with debug libunwind DLL later.

@mstorsjo
Copy link
Contributor

Unfortunately I couldn't find out what is under that failing address.
In all the good frames frameInfo.handler points to https://github.com/rust-lang/rust/blob/91f128baf7704a477ab7c499143a160fb069b3ad/library/std/src/personality/gcc.rs#L244 but for that one problematic frame neither GDB or LLDB can read the memory it points to. Also that address is always small like 0xbc0000, 0x8f0000 (varies between builds but that is expected).
All I know its being set in https://github.com/llvm/llvm-project/blob/8805e5d1b7be72b007448477aa55cc6b104b4842/libunwind/src/UnwindCursor.hpp#L2845 but I wasn't able to get any info from it as the details seem to be optimised out. That was with statically linked debug libunwind, gonna try with debug libunwind DLL later.

Ok. I guess I could try to sit down with it and debug what's going wrong too, some day. The ideal for me, for doing that, would be a build with debug info present, with libunwind linked as a DLL (so it's easy for me to add more debugging printouts in it - for dwarf unwinding, running it in wine doesn't really help at all, as the OS facilities aren't used for unwinding).

@mati865
Copy link
Collaborator

mati865 commented Oct 16, 2022

I think I was able to pinpoint binary with problematic frame and perhaps unsurprisingly it's the binary I'm calling itself...

Part of log with my own prints to list all the modules in which libunwind searches for unwind sections:

module name: D:\Projekty\msys2\MINGW-packages\mingw-w64-rust\src\stage2-bin-debuglevel1-stddebuglevel2-sharedunwind\rustdoc.exe
module name: C:\WINDOWS\SYSTEM32\ntdll.dll
module name: C:\WINDOWS\System32\KERNEL32.DLL
module name: C:\WINDOWS\System32\KERNELBASE.dll
module name: C:\WINDOWS\System32\ucrtbase.dll
module name: D:\Projekty\msys2\MINGW-packages\mingw-w64-rust\src\stage2-bin-debuglevel1-stddebuglevel2-sharedunwind\std-8b196961c6436b7c.dll
module name: C:\WINDOWS\System32\ADVAPI32.dll
module name: C:\WINDOWS\System32\msvcrt.dll
module name: D:\Projekty\msys2\MINGW-packages\mingw-w64-rust\src\stage2-bin-debuglevel1-stddebuglevel2-sharedunwind\test-68ddf291a1346c8d.dll
module name: C:\WINDOWS\System32\WS2_32.dll
module name: D:\Projekty\msys2\MINGW-packages\mingw-w64-rust\src\stage2-bin-debuglevel1-stddebuglevel2-sharedunwind\libc++.dll
module name: C:\WINDOWS\System32\sechost.dll
module name: C:\WINDOWS\System32\RPCRT4.dll
module name: D:\Projekty\msys2\MINGW-packages\mingw-w64-rust\src\stage2-bin-debuglevel1-stddebuglevel2-sharedunwind\rustc_driver-9ec5999558c82475.dll
libunwind: unwind_phase1(ex_ojb=05F7C178): pc=0x113cdced, start_ip=0x113cdc70, func=.anonymous., lsda=0x17d27e70, personality=0x14bb6726
libunwind: unwind_phase1(ex_ojb=05F7C178): calling personality function 14BB6726
libunwind: unwind_phase1(ex_ojb=05F7C178): _URC_CONTINUE_UNWIND        # Getting here means personality worked fine
module name: D:\Projekty\msys2\MINGW-packages\mingw-w64-rust\src\stage2-bin-debuglevel1-stddebuglevel2-sharedunwind\rustdoc.exe
libunwind: unwind_phase1(ex_ojb=05F7C178): pc=0x6b45d7, start_ip=0x6b42b0, func=.anonymous., lsda=0xd98324, personality=0x280000
libunwind: unwind_phase1(ex_ojb=05F7C178): calling personality function 00280000
Signal: SIGSEGV (Segmentation fault)                                   # Cannot read memory at 0x00280000

Which might sound nice but if we compare working and broken binary:

$ ls -lhs rustc.exe rustdoc.exe
76K -rwxr-xr-x 1 mateusz mateusz 73K 10-15 13:18 rustc.exe
89M -rwxr-xr-x 1 mateusz mateusz 89M 10-15 13:19 rustdoc.exe

The problematic one is quite big and has all kind of different symbols that are absent on working one:
nm-rustc.txt
nm-rustdoc.txt

I still plan to debug it one I find some time but providing link to the archive just in case: https://1drv.ms/u/s!AgMYIlqTF8b9gus1M-aZcFfphKAzsg?e=OeDwg4
Left some info inside README.md on how to run it.

@mstorsjo
Copy link
Contributor

I have started looking at this now, and I have almost nailed it down, but not quite.

I noticed that when running this test in wine, it didn't hit the crash. (rustc.exe returns 1 as return code, though, while rustdoc.exe returns 101 though - is this expected?) And when comparing libunwind debug outputs to see where it differed, I noticed that the addresses differed (due to ASLR). To reduce differences, I removed the dynamicbase bit from rustdoc.exe, but then the crash vanished.

When comparing logs from the case in wine (and/or without dynamicbase) and the crashing case, there's a personality pointer in the unwind data, which is supposed to be a null pointer - but when the executable is loaded at a different address, the pointer is non-null. I dug up the exact offset in the binary where this supposedly-null field is, and the binary has got a base relocation there. I.e., if your image normally has got a load address of 0x00400000 and you've got an address of 0x00401234, and at runtime, the image gets loaded at 0x00ff0000 - then that address should be rewritten to 0x00ff1234 too. Well, such a rewrite (base relocation) gets applied on the null pointer, so when the image is loaded at a non-default location, it's no longer null.

Now why doesn't this happen in the rustc.exe case where everything is in a DLL? I don't know. Why doesn't this happen for C++ unwind info? Apparently for the cases where we do have a null personality, we simply don't encode any personality pointer in the unwind data. But here in the Rust generated dwarf unwind info, we have stored a literal pointer, which happens to be null, but ends up getting the base relocation applied.

To figure out why, I'd kinda want to look at how the code generation happens. Are you able to provide LLVM IR (bitcode file or textual) for the object file that contains the symbol __RNvCsak4nujc38YL_7rustdoc9main_args (and the object file itself, if you happen to have it lying around), so that I can run that code generation through (vanilla) LLVM to see what creates it? Or if it's all generated by LTO or something similar, is it possible to get the input files to this - so I can reproduce generating it? I believe that this is a cornercase in dwarf unwind generation for COFF targets, which isn't ever really triggered by the Clang generated stuff. Maybe...

@mstorsjo
Copy link
Contributor

I've tried to see how the dwarf code generation would intentionally generate a null pointer for the personality field, and it does look like that really shouldn't be happening. So I think the unwind info actually does have a reference to a personality function symbol there. But after linking, it's null - but still considered a symbol reference, not an absolute address, so there's a base relocation in it.

I'm not quite sure how this can happen.

I had a suspicion that rust_eh_personality was referenced as a weak symbol, which then didn't end up linked in, which would make the symbol references null. I did try to simulate this situation, but while I can make a null pointer in a binary this way, I don't get any base relocation for it. So I guess it's not this.

It's possible that there's some other special symbol trickery that would provide a null rust_eh_personality which then ends up with a base relocation, but I don't think I manage to guess blindly what's happening.

In any case, the whole rustdoc.exe does seem to lack rust_eh_personality. So I think the more interesting thing to look into, is how rustdoc.exe was linked (lld repro inputs would be awesome!), regenerating the object files that make up it (including __RNvCsak4nujc38YL_7rustdoc9main_args) perhaps isn't the thing I want to look into. But this explains better why this only seems to affect rustdoc.exe but not the DLLs.

@mati865
Copy link
Collaborator

mati865 commented Oct 25, 2022

I noticed that when running this test in wine, it didn't hit the crash. (rustc.exe returns 1 as return code, though, while rustdoc.exe returns 101 though - is this expected?)

Not at all, IIRC that would mean unhandled ICE.
I have also tried launching it under Wine previously but it was still crashing albeit in different way.

And when comparing libunwind debug outputs to see where it differed, I noticed that the addresses differed (due to ASLR). To reduce differences, I removed the dynamicbase bit from rustdoc.exe, but then the crash vanished.

I was planning to test this next this or next weekend 😄
Guess it would be sufficient workaround for MSYS2.

When comparing logs from the case in wine (and/or without dynamicbase) and the crashing case, there's a personality pointer in the unwind data, which is supposed to be a null pointer - but when the executable is loaded at a different address, the pointer is non-null.

Yeah, I was thinking about null pointer but couldn't understand how it could become non-null without memory corruption. Now that makes sense!

But here in the Rust generated dwarf unwind info, we have stored a literal pointer, which happens to be null, but ends up getting the base relocation applied.

Oh, I think I saw literal pointer in some std code but surely it wasn't null...

To figure out why, I'd kinda want to look at how the code generation happens. Are you able to provide LLVM IR (bitcode file or textual) for the object file that contains the symbol __RNvCsak4nujc38YL_7rustdoc9main_args (and the object file itself, if you happen to have it lying around), so that I can run that code generation through (vanilla) LLVM to see what creates it?

It shouldn't be hard but it will take me some time to figure out. Without any changes I can only show stage 1 build dirs (over 9 GiB unpacked) with object files (rlibs) among the other things. Inside there is i686-pc-windows-gnu\stage1-tools\i686-pc-windows-gnu\release\deps\rustdoc_tool_binary-9944fbc221962034.d which contains absolute paths to various rlibs, shared libs and other metadata files. Not the easiest build system to debug things...

https://1drv.ms/u/s!AgMYIlqTF8b9gus1M-aZcFfphKAzsg?e=rc6inR

so that I can run that code generation through (vanilla) LLVM to see what creates it?

That can be painful even after I get IR because of the reasons above.

Or if it's all generated by LTO or something similar, is it possible to get the input files to this - so I can reproduce generating it?

AFAICT no Fat or Thin LTO is involved here, Rust can do it's own kind of LTO before linking step but I think it's also disabled for those builds.

I had a suspicion that rust_eh_personality was referenced as a weak symbol, which then didn't end up linked in, which would make the symbol references null. I did try to simulate this situation, but while I can make a null pointer in a binary this way, I don't get any base relocation for it. So I guess it's not this.

Shouldn't be the case as Rust disables weak symbols for Windows.

It's possible that there's some other special symbol trickery that would provide a null rust_eh_personality which then ends up with a base relocation, but I don't think I manage to guess blindly what's happening.

Yeah, it's lang item so the machinery around it is not exactly trivial to follow.

In any case, the whole rustdoc.exe does seem to lack rust_eh_personality.

Ouch, I didn't see that coming. Could it be rustc.exe exception is both thrown and caught inside rustc_driver-<hash>.dll so it doesn't need personality but in case of rustdoc we throw the exception inside rustdoc.exe but try catching it inside rustc_driver-<hash>.dll?

So I think the more interesting thing to look into, is how rustdoc.exe was linked (lld repro inputs would be awesome!)

Sure, I'll try to obtain it soon.

@mstorsjo
Copy link
Contributor

I noticed that when running this test in wine, it didn't hit the crash. (rustc.exe returns 1 as return code, though, while rustdoc.exe returns 101 though - is this expected?)

Not at all, IIRC that would mean unhandled ICE.

Right, ok - and that's also consistent with this seeming to be a missing personality function, not intended null.

And when comparing libunwind debug outputs to see where it differed, I noticed that the addresses differed (due to ASLR). To reduce differences, I removed the dynamicbase bit from rustdoc.exe, but then the crash vanished.

I was planning to test this next this or next weekend 😄 Guess it would be sufficient workaround for MSYS2.

Well not really, since as we realized later, the issue is that it should be a nonnull rust_eh_personality, but it's just missing for some reason.

It shouldn't be hard but it will take me some time to figure out. Without any changes I can only show stage 1 build dirs (over 9 GiB unpacked) with object files (rlibs) among the other things. Inside there is i686-pc-windows-gnu\stage1-tools\i686-pc-windows-gnu\release\deps\rustdoc_tool_binary-9944fbc221962034.d which contains absolute paths to various rlibs, shared libs and other metadata files. Not the easiest build system to debug things...

https://1drv.ms/u/s!AgMYIlqTF8b9gus1M-aZcFfphKAzsg?e=rc6inR

Thanks, I downloaded this. Unfortunately I don't quite know how to try to rerun the linking of rustdoc.exe here...

I at least managed to located the object file which contains __RNvCsak4nujc38YL_7rustdoc9main_args, and I could see that it at least seems like it does try to reference rust_eh_personality as personality, as it should. So it's only a matter of the linker messing it up somehow (and apparently linking in a null pointer instead of a real symbol!).

I had a suspicion that rust_eh_personality was referenced as a weak symbol, which then didn't end up linked in, which would make the symbol references null. I did try to simulate this situation, but while I can make a null pointer in a binary this way, I don't get any base relocation for it. So I guess it's not this.

Shouldn't be the case as Rust disables weak symbols for Windows.

Ok, good, they're a bit of a mess (even though they should work fine in llvm based mingw environments).

In any case, the whole rustdoc.exe does seem to lack rust_eh_personality.

Ouch, I didn't see that coming. Could it be rustc.exe exception is both thrown and caught inside rustc_driver-<hash>.dll so it doesn't need personality but in case of rustdoc we throw the exception inside rustdoc.exe but try catching it inside rustc_driver-<hash>.dll?

More or less (or maybe vice versa - I think the code in rustdoc.exe was supposed to catch it while it's thrown elsewhere). Anyway, I think the personality function is essential for catching the exception, otherwise it just bypasses that stack frame. I see that rustc.exe also lacks the personality function, but there, all code for throwing/catching the exceptions is within the DLLs that do seem to have the function correctly.

So I think the more interesting thing to look into, is how rustdoc.exe was linked (lld repro inputs would be awesome!)

Sure, I'll try to obtain it soon.

Ok, great!

Are you able to check what the state is for other architecture builds (x86_64 and aarch64?), for rustdoc.exe (and rustc.exe), do they contain the rust_eh_personality symbol, or is it imported from a dll? Checking with llvm-nm (assuming non-stripped binaries) and llvm-readobj --coff-imports should show whether it exists and/or is imported.

@mati865
Copy link
Collaborator

mati865 commented Oct 27, 2022

This now includes all temporary files so it's ~24 GiB unpacked...
https://1drv.ms/u/s!AgMYIlqTF8b9gutY5dUAapLuZTqkAg?e=Si1T1F

Here are all arguments passed to clang for linking:
rustdoc_tool_binary-9944fbc221962034.txt

@mstorsjo
Copy link
Contributor

This now includes all temporary files so it's ~24 GiB unpacked... https://1drv.ms/u/s!AgMYIlqTF8b9gutY5dUAapLuZTqkAg?e=Si1T1F

Here are all arguments passed to clang for linking: rustdoc_tool_binary-9944fbc221962034.txt

Thanks!

The clang arguments included a file D:\temp\rustcoPEZfz\symbols.o which wasn't included, but I left it out, and managed to run the command anyway. And after fixing things up so I can run it, I can reproduce the missing symbol. I noticed that the command line does include -Wl,--gc-sections which seems to be the trigger - if I leave it out, the symbol is kept (and I would presume that unwinding works as intended). I guess it's somewhat understandable if the symbol is only referenced in unwind data, and the GC tree fails to traverse the unwind data.

However, linking C++ code for i686 with -Wl,--gc-sections does seem to work fine, it doesn't end up losing the personality function. I wonder why...

@mstorsjo
Copy link
Contributor

Normally, a relocation against a symbol that has been GC'd away like this would end up as a linker error: https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/lld/COFF/Chunks.cpp#L352

However due to how the DWARF sections work, it's expected to have such dangling references left out there, if things are GC'd, so it ignores that error for such sections: https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/lld/COFF/Chunks.cpp#L328-L333 (Also the error is entirely skipped for anything in mingw mode)

But now I found how this is fixed for the existing C++ cases: llvm/llvm-project@7e07683

I made a patch for LLD that should fix it similarly for this symbol: https://reviews.llvm.org/D136879

@mati865
Copy link
Collaborator

mati865 commented Oct 28, 2022

Terrific!
That seems to have done the trick but there is new issue (we haven't reached it previously): rust-installer.exe exits with Windows error 740: The requested operation requires elevation....

Trying to run it manually:

$ RUST_LOG=debug PATH=src/CLANG32/build/i686-pc-windows-gnu/stage2/bin:$PATH src/CLANG32/build/i686-pc-windows-gnu/stage0-tools-bin/rust-installer.exe
bash: src/CLANG32/build/i686-pc-windows-gnu/stage0-tools-bin/rust-installer.exe: Permission denied

So there is still more work to do on my end.

mstorsjo added a commit to llvm/llvm-project that referenced this issue Oct 28, 2022
…y functions

These need to have special treatment wrt to .eh_frame sections
and GC - as long as we don't have a full parser of the .eh_frame
section in the COFF linker.

This fixes Rust unwind issues on i686 mingw as discussed in
msys2/MINGW-packages#9091.

Differential Revision: https://reviews.llvm.org/D136879
@jeremyd2019
Copy link
Member Author

Terrific! That seems to have done the trick but there is new issue (we haven't reached it previously): rust-installer.exe exits with Windows error 740: The requested operation requires elevation....

Maybe a missing or incorrect manifest? Without a manifest, the Windows compatibility heuristic might be seeing "install" in the name of the exe and assuming it needs elevation.

@mati865
Copy link
Collaborator

mati865 commented Oct 29, 2022

I think Rust binaries have no manifest, except for host compiler built for msvc which enables long paths support.

@jeremyd2019
Copy link
Member Author

Huh, I thought you needed to have an asInvoker manifest to disable the setup heuristic that makes things Windows thinks are installers require elevation....

virnarula pushed a commit to virnarula/llvm-project that referenced this issue Nov 2, 2022
…y functions

These need to have special treatment wrt to .eh_frame sections
and GC - as long as we don't have a full parser of the .eh_frame
section in the COFF linker.

This fixes Rust unwind issues on i686 mingw as discussed in
msys2/MINGW-packages#9091.

Differential Revision: https://reviews.llvm.org/D136879
@lazka
Copy link
Member

lazka commented Nov 4, 2022

hm, I just found a similar issue where clang32 exe is auto-elevated, while mingw32 isn't: mesonbuild/wrapdb#513

@neheb
Copy link
Contributor

neheb commented Nov 4, 2022

Probably add test stuff to https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-cjson/PKGBUILD to replicate.

@jeremyd2019
Copy link
Member Author

jeremyd2019 commented Nov 4, 2022

@lazka
Copy link
Member

lazka commented Nov 4, 2022

yeah, gcc and rust in gcc envs apply our default manifest (https://packages.msys2.org/base/mingw-w64-windows-default-manifest) while that's not the case in the clang ones

@jeremyd2019
Copy link
Member Author

Interesting it only seems to be cropping up on i686... I thought the setup heuristic applied to x86_64 too...

@lazka
Copy link
Member

lazka commented Nov 4, 2022

Interesting it only seems to be cropping up on i686... I thought the setup heuristic applied to x86_64 too...

yeah, see https://learn.microsoft.com/en-us/previous-versions/aa905330(v=msdn.10)#installer-detection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants