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

Compiler Segfault: Running pass 'X86 AT&T-Style Assembly Printer' on function "..." #546

Closed
dymk opened this issue Nov 21, 2013 · 2 comments

Comments

@dymk
Copy link

dymk commented Nov 21, 2013

Environment: OSX Mavericks, 10.9
LDC ~master, LLVM 3.2

This seems to only occur with the -g and -gc switches

payload_ldc_bug.d:

import variant_ldc_bug;

struct RequestAddImageFromPixels {
  int[] pixels;
}

void doSomething()
{
  RequestAddImageFromPixels payload;

  payload.visit!(
    (RequestAddImageFromPixels response)
    {
      foreach(px; response.pixels) {}
    }
  );
}

variant_ldc_bug.d

template visit(Handler ...)
{
  auto visit(VariantType)(VariantType variant)
  {
    visitImpl!(true, VariantType, Handler)(variant);
  }
}

auto visitImpl(bool Strict, VariantType, Handler...)(VariantType )
{
  foreach(dgidx; Handler) {}
}

and command: ldmd2 -gc payload_ldc_bug.d variant_ldc_bug.d

Will result in the following compiler crash:

Codeinator:clean_itr2.reduced dymk$ ldmd2 -gc payload_ldc_bug.d variant_ldc_bug.d
0  ldc2                     0x000000010ce32a05 PrintStackTrace(void*) + 37
1  ldc2                     0x000000010ce32e34 SignalHandler(int) + 452
2  libsystem_platform.dylib 0x00007fff8c0815aa _sigtramp + 26
3  libsystem_malloc.dylib   0x00007fff92330286 tiny_malloc_from_free_list + 1502
4  ldc2                     0x000000010c9aceaa llvm::DwarfDebug::updateSubprogramScopeDIE(llvm::CompileUnit*, llvm::MDNode const*) + 1578
5  ldc2                     0x000000010c9aecfc llvm::DwarfDebug::constructScopeDIE(llvm::CompileUnit*, llvm::LexicalScope*) + 1708
6  ldc2                     0x000000010c9b5a68 llvm::DwarfDebug::endFunction(llvm::MachineFunction const*) + 1352
7  ldc2                     0x000000010c993fb7 llvm::AsmPrinter::EmitFunctionBody() + 3799
8  ldc2                     0x000000010c7ca6b2 llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) + 178
9  ldc2                     0x000000010ca28803 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 99
10 ldc2                     0x000000010cddf899 llvm::FPPassManager::runOnFunction(llvm::Function&) + 313
11 ldc2                     0x000000010cddf0a4 llvm::FunctionPassManagerImpl::run(llvm::Function&) + 196
12 ldc2                     0x000000010cddefa6 llvm::FunctionPassManager::run(llvm::Function&) + 86
13 ldc2                     0x000000010c5c27b7 codegenModule(llvm::TargetMachine&, llvm::Module&, llvm::raw_fd_ostream&, llvm::TargetMachine::CodeGenFileType) + 327
14 ldc2                     0x000000010c5c22ca writeModule(llvm::Module*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 3018
15 ldc2                     0x000000010c5c832c main + 9308
16 libdyld.dylib            0x00007fff8a48d5fd start + 1
Stack dump:
0.  Running pass 'X86 AT&T-Style Assembly Printer' on function '@_D15payload_ldc_bug11doSomethingFZv9__lambda1FNaNbNfS15payload_ldc_bug25RequestAddImageFromPixelsZv'
Error: Error executing /usr/local/bin/ldc2: Segmentation fault: 11
@redstar
Copy link
Member

redstar commented Nov 25, 2013

Thanks for the excellent report. I can reproduce the crash using Linux/x86_64, too.

redstar pushed a commit that referenced this issue Sep 27, 2014
Typo in core.simd, market -> marked
@dnadlinger
Copy link
Member

Seems to be fixed in LDC master and/or LLVM 3.5 (tested with a debug build, and still no assertion is hit):

LDC - the LLVM D compiler (bff766):
  based on DMD v2.066 and LLVM 3.5.0svn
  Default target: x86_64-unknown-linux-gnu
  Host CPU: corei7-avx

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

No branches or pull requests

3 participants