LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 22096 - Regression(225083:225087): Assertion failed: DISubprogram(Scope).describes(MF->getFunction()
Summary: Regression(225083:225087): Assertion failed: DISubprogram(Scope).describes(MF...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: LLVM Codegen (show other bugs)
Version: unspecified
Hardware: PC All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
: 22114 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-01-05 12:53 PST by Nico Weber
Modified: 2015-01-10 23:21 PST (History)
10 users (show)

See Also:
Fixed By Commit(s):


Attachments
repro (490.26 KB, application/zip)
2015-01-05 13:34 PST, Nico Weber
Details
reduce testcase (769 bytes, application/octet-stream)
2015-01-05 18:38 PST, Rafael Ávila de Espíndola
Details
Simpler test case (170 bytes, text/x-c)
2015-01-06 07:23 PST, Jörg Sonnenberger
Details
reduced.cc (239 bytes, text/plain)
2015-01-06 12:25 PST, Saleem Abdulrasool
Details
reduced.cc (273 bytes, text/plain)
2015-01-06 12:59 PST, Saleem Abdulrasool
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nico Weber 2015-01-05 12:53:36 PST
Our Chromium clang/win bots started seeing

Assertion failed: DISubprogram(Scope).describes(MF->getFunction()), file C:\b\build\slave\CrWinClang\build\src\third_party\llvm\lib\CodeGen\LexicalScopes.cpp, line 179

again. This started when clang updated from 225082 to 225087 on the bot. r225083 or (more likely) r225085 look very related.
Comment 1 Nico Weber 2015-01-05 13:34:42 PST
Created attachment 13629 [details]
repro

"D:\\src\\llvm-ninja-rel64\\bin\\clang-cl.exe" "-cc1" "-triple" "i386-pc-windows-msvc" "-emit-obj" "-disable-free" "-main-file-name" "quic_crypto_server_config_test.cc" "-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim" "-relaxed-aliasing" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-target-cpu" "pentium4" "--dependent-lib=libcmt" "--dependent-lib=oldnames" "-fno-rtti-data" "-fdiagnostics-format" "msvc-fallback" "-gline-tables-only" "-dwarf-column-info" "-ffunction-sections" "-fdata-sections" "-coverage-file" "D:\\src\\chromefetch\\src\\out\\Release\\quic_crypto_server_config_test.cc" "-resource-dir" "D:\\src\\llvm-ninja-rel64\\bin\\..\\lib\\clang\\3.6.0" "-internal-isystem" "D:\\src\\llvm-ninja-rel64\\bin\\..\\lib\\clang\\3.6.0\\include" "-internal-isystem" "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\include" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um" "-internal-isystem" "C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt" "-O2" "-std=c++11" "-fdeprecated-macro" "-fdebug-compilation-dir" "D:\\src\\chromefetch\\src\\out\\Release" "-ferror-limit" "19" "-fmessage-length" "135" "-mstackrealign" "-fms-extensions" "-fms-compatibility" "-fms-compatibility-version=18.0" "-fdelayed-template-parsing" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-vectorize-loops" "-vectorize-slp" "-o" "obj\\net\\quic\\crypto\\net_unittests.quic_crypto_server_config_test.obj" "-x" "c++" -w foo.ii
Comment 2 Nico Weber 2015-01-05 13:41:26 PST
Shorter command that probably will repro this on posix too (still building a new enough clang to check):

"D:\\src\\llvm-ninja-rel64\\bin\\clang-cl.exe" "-cc1" "-triple" "i386-pc-windows-msvc" "-emit-obj" "-gline-tables-only" "-O2" "-std=c++11" "-fms-extensions" "-fms-compatibility" "-fdelayed-template-parsing" "-x" "c++" -w foo.ii
Comment 3 Nico Weber 2015-01-05 13:51:17 PST
Yup, reproduces on posix too. Delta is running now, but the file is pretty big and takes ~5s per run, so it'll likely take several hours. If you see what's wrong without getting a reduced repro, you might want to not wait for the reduced repro :-)
Comment 4 Rafael Ávila de Espíndola 2015-01-05 18:38:35 PST
Created attachment 13635 [details]
reduce testcase

clang -cc1 -triple i386-pc-windows-msvc -emit-llvm-bc -gline-tables-only foo.ii -o test.bc
opt  test.bc -o test2.bc -sroa
opt test2.bc -o test3.bc -inline
llc test3.bc #crashes
Comment 5 Jörg Sonnenberger 2015-01-06 07:23:31 PST
Created attachment 13638 [details]
Simpler test case
Comment 6 Jörg Sonnenberger 2015-01-06 07:24:41 PST
(In reply to comment #5)
> Created attachment 13638 [details]
> Simpler test case

Build with -O2 -g for this one.
Comment 7 Saleem Abdulrasool 2015-01-06 12:25:17 PST
Created attachment 13639 [details]
reduced.cc

This generates far less IR, and still generates the same assertion.
Comment 8 Saleem Abdulrasool 2015-01-06 12:59:08 PST
Created attachment 13640 [details]
reduced.cc

Now occurs without optimizations.
Comment 9 David Majnemer 2015-01-07 04:20:17 PST
normal c++ program, no objective-c blocks or nothin', no optimizations needed to trigger:
template <class> struct c {
  c();
  template <class U> __attribute__((__always_inline__)) c(c<U>) {}
};
struct {
  c<double> v = c<int>();
} o;
Comment 10 David Majnemer 2015-01-07 04:20:35 PST
*** Bug 22114 has been marked as a duplicate of this bug. ***
Comment 11 Nico Weber 2015-01-07 11:56:41 PST
Here's the reduction I arrived at, doesn't use blocks, any always_inline attributes, or even templates:

$ cat repro.ii
class _String_val {
  union _Bxty { int i; } _Bx;
};
struct string : public _String_val {
  string(const char *_Ptr) : _String_val() {}
};


int ConvertIPv4NumberToIPv6Number(int);
struct IPEndPoint {
  IPEndPoint();
  IPEndPoint(const int &address, int port);
  const int &address() const {}
};

struct SourceAddressTokenTest {
  SourceAddressTokenTest()
      : ip4_dual_(ConvertIPv4NumberToIPv6Number(ip4_.address()), 1) {}
  const string kPrimary = "<primary>";
  IPEndPoint ip4_;
  IPEndPoint ip4_dual_;
} s;
$ /Users/thakis/src/llvm-build/bin/clang "-cc1" "-triple" "i386-pc-windows-msvc" "-emit-obj" "-gline-tables-only" "-O2" "-std=c++11" "-fms-extensions" "-fms-compatibility" "-fdelayed-template-parsing" "-x" "c++" -w repro.ii
Assertion failed: (DISubprogram(Scope).describes(MF->getFunction())), function getOrCreateRegularScope, file /Users/thakis/src/llvm-svn/lib/CodeGen/LexicalScopes.cpp, line 179.
0  clang                    0x00000001036b4839 llvm::sys::PrintStackTrace(__sFILE*) + 57
1  clang                    0x00000001036b500b SignalHandler(int) + 571
Comment 12 Nico Weber 2015-01-07 12:27:36 PST
I reverted r225085 in r225361. This made the assert I was seeing go away. Do others still see their asserts?
Comment 13 Nico Weber 2015-01-07 12:34:20 PST
I tried some of the other reductions on this bug, they don't crash for me anymore either. I'll mark this as closed; shout if you're still seeing it.
Comment 14 Jörg Sonnenberger 2015-01-08 06:10:47 PST
The State.cpp issue is still present -- inlining of a global constructor.
Comment 15 Nico Weber 2015-01-08 13:38:34 PST
Huh strange, that was one of the ones I tried:

$ bin/clang -cc1 -w -triple i386-pc-windows-msvc -O2  -emit-obj -g ~/Downloads/State-fc3936.cpp  
$ bin/clang -cc1 -w -triple i386-pc-windows-msvc  -emit-obj -g ~/Downloads/State-fc3936.cpp
$ bin/clang -cc1 -w -O2 -emit-obj -g ~/Downloads/State-fc3936.cpp  
$ # no crashes

I tried a few more flag combinations I could think of. What command are you running to see a crash?

$ bin/clang --version
clang version 3.6.0 (trunk 225408)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
Comment 16 Jörg Sonnenberger 2015-01-08 14:57:37 PST
(In reply to comment #15)
> Huh strange, that was one of the ones I tried:
> 
> $ bin/clang -cc1 -w -triple i386-pc-windows-msvc -O2  -emit-obj -g
> ~/Downloads/State-fc3936.cpp  
> $ bin/clang -cc1 -w -triple i386-pc-windows-msvc  -emit-obj -g
> ~/Downloads/State-fc3936.cpp
> $ bin/clang -cc1 -w -O2 -emit-obj -g ~/Downloads/State-fc3936.cpp  
> $ # no crashes
> 
> I tried a few more flag combinations I could think of. What command are you
> running to see a crash?
> 
> $ bin/clang --version
> clang version 3.6.0 (trunk 225408)
> Target: x86_64-apple-darwin13.4.0
> Thread model: posix

Hm. Difference in the way constructors are done, maybe?

clang -O2 -g -target x86_64-linux -c State-fc3936.cpp
Comment 17 David Blaikie 2015-01-09 17:02:40 PST
Reverted in r225555.

Sorry for the delay - been a busy week.

Between this bug and the review thread I have 4 crash test cases, one that was resolved by Nico reverting one of the subsequent patches, the other 3 still crash until I submitted that revert. I'll work up more isolated test cases for them and then see about fixing them before resubmitting this patch.

If anyone else happens across any more reductions it'd be great for me to have them so I can address/verify them before recommitting.
Comment 18 Nick Lewycky 2015-01-09 19:40:23 PST
Here's another testcase:

struct A {
  A(int);
  ~A() { this->m_fn1(); }
  void m_fn1();
};

struct Class {
  Class(A);
};
template <typename> struct B {
  static Class *m_theClass;
  void m_fn1() { B<int>::m_theClass; }
};

template <typename T>
Class *B<T>::m_theClass = new Class(0);

$ clang -cc1 -emit-obj -w -fexceptions -fcxx-exceptions -gline-tables-only -O2 -std=gnu++11
Comment 19 Nico Weber 2015-01-10 23:21:09 PST
Thanks for the revert!