New user self-registration is disabled due to spam. For an account please email bugs-admin@lists.llvm.org with your e-mail address and full name.

Bug 40184 - Assertion failed: Subtarget.isCallingConvWin64(MF.getFunction().getCallingConv()) && "Funclets should only be present on Win64"
Summary: Assertion failed: Subtarget.isCallingConvWin64(MF.getFunction().getCallingCon...
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Backend: AArch64 (show other bugs)
Version: trunk
Hardware: PC Windows NT
: P enhancement
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-30 04:55 PST by Zufu Liu
Modified: 2019-02-28 12:39 PST (History)
12 users (show)

See Also:
Fixed By Commit(s):


Attachments
Stacktrace for Clang svn 347735 and 350161 (21.42 KB, text/plain)
2018-12-30 04:55 PST, Zufu Liu
Details
Preprocessed sources and associated run script (106.21 KB, application/x-zip-compressed)
2019-02-26 04:13 PST, Zufu Liu
Details
Preprocessed source for Editor.cxx (461.44 KB, application/x-zip-compressed)
2019-02-26 17:34 PST, Zufu Liu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zufu Liu 2018-12-30 04:55:20 PST
Created attachment 21280 [details]
Stacktrace for Clang svn 347735 and 350161

Step to Produce:

1. Install latest Visual Studio 2017 15.9.4 and Windows 10 SDK 10.0.17763.0

2. Install LLVM for Visual Studio from https://github.com/zufuliu/llvm-utils/releases, using LLVM_VS2017.zip. This MSBuild source code is very similar to source in http://llvm.org/svn/llvm-project/llvm/trunk/tools/msbuild, except I added ARM64 support (and other small changes):

    <AdditionalOptions Condition="'$(Platform)' == 'ARM64'">--target=aarch64-pc-windows-msvc $(ClangClAdditionalOptions) %(AdditionalOptions)</AdditionalOptions>

3. Get source code for https://github.com/zufuliu/notepad2, Open build\VS2017\Notepad2.sln, select LLVMDebug + ARM64 and LLVMRelease + ARM64 to build both project, result:

                    LLVMDebug + ARM64           LLVMRelease + ARM64
    metapath        OK                          OK
    Notepad2        OK                          Clang Crashed for both c++17 and c++2a


Host Windows 10 x64 Pro 1803 v10.0.17134.472 on i5-4570.

Detail stacktrace ("/showFilenames -v" is added to LLVM -> Additional Compiler Options) for c++2a (c++17 is very similar) is in attachment.

SVN r347735 from http://llvm.org/builds/:

1>Assertion failed: Subtarget.isCallingConvWin64(MF.getFunction().getCallingConv()) && "Funclets should only be present on Win64", file C:\src\llvm_package_347735\llvm\lib\Target\AArch64\AArch64FrameLowering.cpp, line 1506


Self build 350161 trunk:

1>Assertion failed: unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && "Invalid Object Idx!", file H:\llvm\llvm\include\llvm/CodeGen/MachineFrameInfo.h, line 489
Comment 1 Reid Kleckner 2019-02-21 13:33:30 PST
Has this been fixed since the latest work on Win ARM64 EH?
Comment 2 Eli Friedman 2019-02-21 14:20:17 PST
The "isCallingConvWin64" assertion should be fixed.  I don't recall ever seeing the other one.
Comment 3 Zufu Liu 2019-02-22 04:51:22 PST
Thanks for looking on this, I will build clang from GitHub source with Visual Studio 2017 15.9.7 tomorrow, and test if it working.
Comment 4 Zufu Liu 2019-02-22 21:24:41 PST
Still fail (build from llvm-svn: 354719, git commit: 6ac16e91f6dff44cfdd3fc4092a06ea383670c5c):

Assertion failed: unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && "Invalid Object Idx!", file H:\llvm\llvm\llvm\include\llvm/CodeGen/MachineFrameInfo.h, line 488
which point to:

  int64_t getObjectSize(int ObjectIdx) const {
    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
           "Invalid Object Idx!");
    return Objects[ObjectIdx+NumFixedObjects].Size;
  }
Comment 5 Eli Friedman 2019-02-25 11:40:40 PST
Normally when clang crashes, it generates two files: one with preprocessed source, and one with the invocation, and indicates where they are on stderr.  If they are there, can you attach those?  Not sure off the top of my head if it works with clang-cl, but I would be sort of surprised if it doesn't.  (If it doesn't work, that's something we should probably fix.)

If that isn't working for some reason, can you generate preprocessed source for the file in question by passing /P?
Comment 6 Zufu Liu 2019-02-26 04:13:06 PST
Created attachment 21514 [details]
Preprocessed sources and associated run script

Preprocessed sources and associated run script by building notepad2 with `-v /showFilenames`, not `/P` (which cause link error).
Comment 7 Zufu Liu 2019-02-26 04:30:41 PST
The error (llvm-svn: 354849, git: c6d54ae9daad8fbcf26bbff2be6844bf05c19f6e):

1>Assertion failed: unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && "Invalid Object Idx!", file H:\llvm\llvm\llvm\include\llvm/CodeGen/MachineFrameInfo.h, line 488

1>clang-cl: error: clang frontend command failed due to signal (use -v to see invocation)
1>clang version 9.0.0 (https://github.com/llvm/llvm-project.git c6d54ae9daad8fbcf26bbff2be6844bf05c19f6e)
1>Target: aarch64-pc-windows-msvc
1>Thread model: posix
1>InstalledDir: F:\Dev\LLVM\bin


Due to upload limitation (1000K), other preprocessed sources (total 182MB) not included in the attachment. Maybe you can build notepad2 (3-Clause BSD) yourself to get these files (see "Step to Produce" at the beginning of this bug report).
Comment 8 Eli Friedman 2019-02-26 16:49:35 PST
Hmm, strange build system; usually it doesn't pass a bunch of files to the compiler at the same time.  It looks like from your stacktrace the one that's actually crashing is PlatWin.cxx?
Comment 9 Zufu Liu 2019-02-26 17:34:40 PST
Created attachment 21515 [details]
Preprocessed source for Editor.cxx

Preprocessed source for Editor.cxx as this is the last file from build command.
Comment 10 Zufu Liu 2019-02-26 17:40:10 PST
I think there is some bug in the optimizer.
The project build successfully when optimization is disabled (/Od, or <Optimization>Disabled</Optimization>) in debug and release mode. Crashed only when optimization is enabled.
/Od
Comment 11 Zufu Liu 2019-02-26 17:46:10 PST
(In reply to Zufu Liu from comment #10)
> I think there is some bug in the optimizer.
> The project build successfully when optimization is disabled (/Od, or
> <Optimization>Disabled</Optimization>) in debug and release mode. Crashed
> only when optimization is enabled.
> /Od

Crashed in both debug and release mode when optimization is enabled.
/O1 <Optimization>MinSpace</Optimization>
/O2 <Optimization>MaxSpeed</Optimization>
/Os <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
/Ot <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
Comment 12 Eli Friedman 2019-02-26 18:19:47 PST
Okay, I can reproduce with that.  Looks like a recent regression.
Comment 13 Eli Friedman 2019-02-26 19:13:58 PST
I think I found the problem. Reduced testcase:

void g();
void f(int x) {
  try {
    if (x!=0)
      g();
  }
  catch (...) {
  }
}

I don't think it's a regression from the initial AArch64 EH patches; not sure why we haven't run into this before.
Comment 14 Eli Friedman 2019-02-27 18:03:13 PST
https://reviews.llvm.org/D58752
Comment 15 Zufu Liu 2019-02-28 02:05:46 PST
(In reply to Eli Friedman from comment #14)
> https://reviews.llvm.org/D58752

Thanks, with patch at D58752 clang not crashed.
Comment 16 Eli Friedman 2019-02-28 12:39:48 PST
Merged to trunk.