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

ld.lld crashing when linking Gimp 3 (2.99) #57243

Closed
hmartinez82 opened this issue Aug 19, 2022 · 12 comments · Fixed by llvm/llvm-project-release-prs#129
Closed

ld.lld crashing when linking Gimp 3 (2.99) #57243

hmartinez82 opened this issue Aug 19, 2022 · 12 comments · Fixed by llvm/llvm-project-release-prs#129
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] lld:COFF release:backport release:merged

Comments

@hmartinez82
Copy link

hmartinez82 commented Aug 19, 2022

With Clang 14.0.6 from Mingw64/MSYS2

/bin/sh ../libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc  -g -O2 -Wall -Wdeclaration-after-statement -Wmissing-prototypes -Werror=missing-prototypes -Wstrict-prototypes -Wmissing-declarations -Winit-self -Wpointer-arith -Wold-style-definition -Wmissing-format-attribute -Wformat-security  -Wtype-limits -fno-common -fdiagnostics-show-option -Wreturn-type   -mms-bitfields  -Wl,-u,gimp_vectors_undo_get_type -Wl,-u,gimp_vectors_mod_undo_get_type -Wl,-u,gimp_config_param_spec_duplicate -Wl,-u,gimp_operations_init -Wl,-u,xcf_init -Wl,-u,internal_procs_init -Wl,-u,gimp_pdb_compat_procs_register -Wl,-u,gimp_plug_in_manager_restore -Wl,-u,gimp_layer_mode_is_legacy -Wl,-u,gimp_parallel_init -Wl,-u,gimp_async_set_new -Wl,-u,gimp_uncancelable_waitable_new -mwindows -Wl,--tsaware   -Wl,-u,gimp_lebl_dialog -Wl,-u,gimp_core_pixbufs_get_resource -Wl,-u,gimp_tool_cursors_get_resource -L/clang64/Lib/x86  -o gimp-2.99.exe app.o errors.o language.o sanity.o signals.o tests.o unique.o gimp-debug.o gimp-log.o gimp-update.o gimp-version.o main.o gui/libappgui.a menus/libappmenus.a actions/libappactions.a dialogs/libappdialogs.a tools/libapptools.a display/libappdisplay.a propgui/libapppropgui.a widgets/libappwidgets.a ../libgimpwidgets/libgimpwidgets-3.0.la -LD:/msys64/clang64/lib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lhid -lwinspool -lcomctl32 -lcomdlg32 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl   xcf/libappxcf.a pdb/libappinternal-procs.a pdb/libapppdb.a plug-in/libappplug-in.a vectors/libappvectors.a core/libappcore.a file/libappfile.a file-data/libappfile-data.a text/libapptext.a paint/libapppaint.a operations/libappoperations.a operations/layer-modes/libapplayermodes.a operations/layer-modes-legacy/libapplayermodeslegacy.a gegl/libappgegl.a config/libappconfig.a ../libgimpconfig/libgimpconfig-3.0.la ../libgimpmath/libgimpmath-3.0.la ../libgimpthumb/libgimpthumb-3.0.la ../libgimpcolor/libgimpcolor-3.0.la ../libgimpmodule/libgimpmodule-3.0.la ../libgimpbase/libgimpbase-3.0.la -LD:/msys64/clang64/lib -lappstream-glib -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lintl  -LD:/msys64/clang64/lib -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lintl  -LD:/msys64/clang64/lib -lfreetype  -LD:/msys64/clang64/lib -lfontconfig -lfreetype  -LD:/msys64/clang64/lib -lpangocairo-1.0 -lcairo -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lintl -lharfbuzz -lfontconfig -lfreetype  -LD:/msys64/clang64/lib -lharfbuzz  -LD:/msys64/clang64/lib -lcairo   -LD:/msys64/clang64/lib -lgmodule-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl  -LD:/msys64/clang64/lib -lgegl-0.4 -lgegl-npd-0.4 -lgmodule-2.0 -ljson-glib-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -lbabl-0.1  -LD:/msys64/clang64/lib -lgobject-2.0 -lglib-2.0 -lintl  -LD:/msys64/clang64/lib -llcms2  -LD:/msys64/clang64/lib -lgexiv2 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl  -lz  -LD:/msys64/clang64/lib -larchive  -LD:/msys64/clang64/lib -lmypaint -ljson-c -lgobject-2.0 -lglib-2.0 -lintl    -lintl    -lpsapi -ldbghelp -lrpcrt4 -lexchndl gimp-2.99.rc.o -lexchndl
libtool: link: x86_64-w64-mingw32-gcc -g -O2 -Wall -Wdeclaration-after-statement -Wmissing-prototypes -Werror=missing-prototypes -Wstrict-prototypes -Wmissing-declarations -Winit-self -Wpointer-arith -Wold-style-definition -Wmissing-format-attribute -Wformat-security -Wtype-limits -fno-common -fdiagnostics-show-option -Wreturn-type -mms-bitfields -Wl,-u -Wl,gimp_vectors_undo_get_type -Wl,-u -Wl,gimp_vectors_mod_undo_get_type -Wl,-u -Wl,gimp_config_param_spec_duplicate -Wl,-u -Wl,gimp_operations_init -Wl,-u -Wl,xcf_init -Wl,-u -Wl,internal_procs_init -Wl,-u -Wl,gimp_pdb_compat_procs_register -Wl,-u -Wl,gimp_plug_in_manager_restore -Wl,-u -Wl,gimp_layer_mode_is_legacy -Wl,-u -Wl,gimp_parallel_init -Wl,-u -Wl,gimp_async_set_new -Wl,-u -Wl,gimp_uncancelable_waitable_new -mwindows -Wl,--tsaware -Wl,-u -Wl,gimp_lebl_dialog -Wl,-u -Wl,gimp_core_pixbufs_get_resource -Wl,-u -Wl,gimp_tool_cursors_get_resource -o .libs/gimp-2.99.exe app.o errors.o language.o sanity.o signals.o tests.o unique.o gimp-debug.o gimp-log.o gimp-update.o gimp-version.o main.o -Wl,-luuid gimp-2.99.rc.o  -L/clang64/Lib/x86 gui/libappgui.a menus/libappmenus.a actions/libappactions.a dialogs/libappdialogs.a tools/libapptools.a display/libappdisplay.a propgui/libapppropgui.a widgets/libappwidgets.a ../libgimpwidgets/.libs/libgimpwidgets-3.0.a -LD:/msys64/clang64/lib -lmscms -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshell32 -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lhid -lwinspool -lcomctl32 -lcomdlg32 -lpangowin32-1.0 -latk-1.0 -lcairo-gobject xcf/libappxcf.a pdb/libappinternal-procs.a pdb/libapppdb.a plug-in/libappplug-in.a vectors/libappvectors.a core/libappcore.a file/libappfile.a file-data/libappfile-data.a text/libapptext.a paint/libapppaint.a operations/libappoperations.a operations/layer-modes/libapplayermodes.a operations/layer-modes-legacy/libapplayermodeslegacy.a gegl/libappgegl.a config/libappconfig.a ../libgimpconfig/.libs/libgimpconfig-3.0.a ../libgimpmath/.libs/libgimpmath-3.0.a ../libgimpthumb/.libs/libgimpthumb-3.0.a ../libgimpcolor/.libs/libgimpcolor-3.0.a ../libgimpmodule/.libs/libgimpmodule-3.0.a /d/Dev/Github/gimp/build_clang64/libgimpconfig/.libs/libgimpconfig-3.0.a /d/Dev/Github/gimp/build_clang64/libgimpcolor/.libs/libgimpcolor-3.0.a /d/Dev/Github/gimp/build_clang64/libgimpmath/.libs/libgimpmath-3.0.a /d/Dev/Github/gimp/build_clang64/libgimpbase/.libs/libgimpbase-3.0.a ../libgimpbase/.libs/libgimpbase-3.0.a -lole32 -lappstream-glib -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpangoft2-1.0 -lpango-1.0 -lfontconfig -lfreetype -lharfbuzz -lcairo -lgegl-0.4 -lgegl-npd-0.4 -lgmodule-2.0 -ljson-glib-1.0 -lbabl-0.1 -llcms2 -lgexiv2 -lgio-2.0 -lz -larchive -lmypaint -ljson-c -lgobject-2.0 -lglib-2.0 -lintl -lpsapi -ldbghelp -lrpcrt4 -lexchndl
ld.lld: warning: sanity.o: locally defined symbol imported: gimp_major_version (defined in libgimpbase-3.0.a(gimpenv.o)) [LNK4217]
ld.lld: warning: sanity.o: locally defined symbol imported: gimp_minor_version (defined in libgimpbase-3.0.a(gimpenv.o)) [LNK4217]
ld.lld: warning: sanity.o: locally defined symbol imported: gimp_micro_version (defined in libgimpbase-3.0.a(gimpenv.o)) [LNK4217]
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
#0 0x00007ff7cc9f11c4 void std::__1::vector<lld::coff::Baserel, std::__1::allocator<lld::coff::Baserel> >::emplace_back<unsigned int>(unsigned int&&) (D:\msys64\clang64\bin\ld.lld.exe+0x2911c4)
#1 0x00007ff84299d0bd std::__1::__function::__base<void ()>::~__base() (D:\msys64\clang64\bin\libLLVM-14.dll+0xdd0bd)
#2 0x00007ff84299cfbc std::__1::__split_buffer<std::__1::function<void ()>*, std::__1::allocator<std::__1::function<void ()>*> >::push_front(std::__1::function<void ()>*&&) (D:\msys64\clang64\bin\libLLVM-14.dll+0xdcfbc)
#3 0x00007ff84299bdfd std::__1::vector<std::__1::thread, std::__1::allocator<std::__1::thread> >::__append(unsigned long long) (D:\msys64\clang64\bin\libLLVM-14.dll+0xdbdfd)
#4 0x00007ff84299bea0 std::__1::vector<std::__1::thread, std::__1::allocator<std::__1::thread> >::__append(unsigned long long) (D:\msys64\clang64\bin\libLLVM-14.dll+0xdbea0)
#5 0x00007ff8c37a6c0c (C:\Windows\System32\ucrtbase.dll+0x26c0c)
#6 0x00007ff8c50354e0 (C:\Windows\System32\KERNEL32.DLL+0x154e0)
#7 0x00007ff8c618485b (C:\Windows\SYSTEM32\ntdll.dll+0x485b)
x86_64-w64-mingw32-gcc: error: linker command failed due to signal (use -v to see invocation)
make[3]: *** [Makefile:1061: gimp-2.99.exe] Error 1
make[3]: Leaving directory '/d/Dev/Github/gimp/build_clang64/app'
make[2]: *** [Makefile:1306: all-recursive] Error 1
make[2]: Leaving directory '/d/Dev/Github/gimp/build_clang64/app'
make[1]: *** [Makefile:865: all-recursive] Error 1
make[1]: Leaving directory '/d/Dev/Github/gimp/build_clang64'
make: *** [Makefile:768: all] Error 2
clang version 14.0.6
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: D:/msys64/clang64/bin
@EugeneZelenko EugeneZelenko added lld:COFF crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Aug 19, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 19, 2022

@llvm/issue-subscribers-lld-coff

@mstorsjo
Copy link
Member

For anyone to be able to reproduce it (without doing the same full build and hoping to trigger the same cases) - can you rerun the linking command with -Wl,--reproduce=repro.tar and share the produced repro.tar file somewhere for us to download? That produces a file that contains all the input files that ended up when you linked, so that it's possible to exactly replicate the issue.

@hmartinez82
Copy link
Author

hmartinez82 commented Aug 19, 2022

Here repro.tar.xz : https://www.dropbox.com/sh/afep37myphw5mnx/AACf8sHrZ_ZhVkFL8bQ2AceRa/repro.tar.xz?dl=1

The issue happens in the very last end of the build when linking the main gimp executable.

@mstorsjo
Copy link
Member

Thanks! I've managed to reproduce the issue, and I understand what's going on. (The problem is that --undefined/-u options to the linker, ends up pulling in an object file late in the process, and this object contains a dllexport directive, which then does't get handled correctly.) I'll try to post a patch that fixes it within the next few days.

@mstorsjo
Copy link
Member

The fix suggestion is in https://reviews.llvm.org/D132361. Headsup @tru @tstellar - this fix would be nice to get into the 15.x release too (once it passes review), if we're not too late for that.

@tru tru added this to the LLVM 15.0.0 Release milestone Aug 22, 2022
@tru
Copy link
Collaborator

tru commented Aug 22, 2022

As long as the fix lands within two weeks it can go into the final 15.0.0. Otherwise it will have to wait until 15.0.1.

@tru
Copy link
Collaborator

tru commented Aug 25, 2022

@mstorsjo What's the status of this? RC3 is just about to be tagged and I will be very hesitant to take anything after that unless it's really critical.

@mstorsjo
Copy link
Member

@mstorsjo What's the status of this? RC3 is just about to be tagged and I will be very hesitant to take anything after that unless it's really critical.

I've updated https://reviews.llvm.org/D132361 according to @rnk's suggestion, but he hasn't had time to re-review it yet (although I don't foresee him having further comments on it after that). But apparently @mati865 just did approve it, so I guess I could land it and file the backport request.

@mstorsjo
Copy link
Member

Reopening for backport to 15.x

@mstorsjo
Copy link
Member

/cherry-pick af39e6f

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 25, 2022

/branch llvm/llvm-project-release-prs/issue57243

llvmbot pushed a commit to llvm/llvm-project-release-prs that referenced this issue Aug 25, 2022
When an object file contains an export directive, we normally do some
amount of deferred processing of them at the end of the linking
process. The -includeoptional option was handled after this, and
any object files (defining new exports) weren't handled.

Move the handling of the -includeoptional into the same late loop
which does the fixups for e.g. export directives.

Ideally, this would also be done for object files that are pulled
in by the wrap options, and for mingw autoimports, but those changes
require more modifications, to make them safe for potentially
being executed multiple times.

This fixes llvm/llvm-project#57243.

Differential Revision: https://reviews.llvm.org/D132361

(cherry picked from commit af39e6f)
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 25, 2022

/pull-request llvm/llvm-project-release-prs#129

tru pushed a commit to llvm/llvm-project-release-prs that referenced this issue Aug 25, 2022
When an object file contains an export directive, we normally do some
amount of deferred processing of them at the end of the linking
process. The -includeoptional option was handled after this, and
any object files (defining new exports) weren't handled.

Move the handling of the -includeoptional into the same late loop
which does the fixups for e.g. export directives.

Ideally, this would also be done for object files that are pulled
in by the wrap options, and for mingw autoimports, but those changes
require more modifications, to make them safe for potentially
being executed multiple times.

This fixes llvm/llvm-project#57243.

Differential Revision: https://reviews.llvm.org/D132361

(cherry picked from commit af39e6f)
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
When an object file contains an export directive, we normally do some
amount of deferred processing of them at the end of the linking
process. The -includeoptional option was handled after this, and
any object files (defining new exports) weren't handled.

Move the handling of the -includeoptional into the same late loop
which does the fixups for e.g. export directives.

Ideally, this would also be done for object files that are pulled
in by the wrap options, and for mingw autoimports, but those changes
require more modifications, to make them safe for potentially
being executed multiple times.

This fixes llvm/llvm-project#57243.

Differential Revision: https://reviews.llvm.org/D132361

(cherry picked from commit af39e6f6fc905f3c067f022fb44136779d2f9c84)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] lld:COFF release:backport release:merged
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants