llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.91k stars 11.94k forks source link

MultiSource/Applications/spiff needs 1.2G virtual memory, crashes with ulimit 300 #7157

Open edwintorok opened 14 years ago

edwintorok commented 14 years ago
Bugzilla Link 6785
Version unspecified
OS Linux
CC @lattner,@pwo

Extended Description

RunSafely sets a 300MB ulimit -v, and this causes MultiSource/Applications/spiff to crash on x86-64.

If I change the limit to 1200000, the test passes. This is not a regression if we look at the behavior: in LLVM 2.6 it has run out of memory too on all configurations, including native: Out of Memory exit 2

The difference is that now we crash when running out of memory, so I don't think this is a release blocker.

Something should be done for llvm 2.8, either make this test use less memory, or increase the limit in RunSafely.

pwo commented 14 years ago

This is a issue on llvm 2.7 freebsd/i386 too, the teste goes up to 580Mb RSS.

edwintorok commented 14 years ago

To fix the crash we could add an if in Allocator.cpp, here: MemSlab Slab = (MemSlab)Allocator.Allocate(Size, 0);

  • if (Slab) {
  • Slab->Size = Size;
  • Slab->NextPtr = 0;
  • }

And return early here: MemSlab *NewSlab = Allocator.Allocate(SlabSize);

  • if (!NewSlab)
  • return 0;

But then we hit this assert: assert(CurPtr <= End && "Unable to allocate memory!"); return Ptr; }

Even if I change that assert to return 0 (mem allocation failure is a real runtime condition, hence it shouldn't handled via asserts), I then crash in FoldingSetNode:

Thats because I made a mistake in my patch and inverted the condition (it returned 0 on success). I'll test to see if the correct patch makes this spiff crash go away.

lattner commented 14 years ago

Ok, well the jit is probably dying because it shares memory with that app. Feel free to hack the spiff code to reduce the problem size.

edwintorok commented 14 years ago

spiff itself:

$ cat Output/spiff.out-nat Out of Memory exit 2

Except for the JIT, in which case the JIT itself crashes.

lattner commented 14 years ago

Is spiff itself running out of memory, or some llvm tool when building it?

edwintorok commented 14 years ago

To fix the crash we could add an if in Allocator.cpp, here: MemSlab Slab = (MemSlab)Allocator.Allocate(Size, 0);

And return early here: MemSlab *NewSlab = Allocator.Allocate(SlabSize);

But then we hit this assert: assert(CurPtr <= End && "Unable to allocate memory!"); return Ptr; }

Even if I change that assert to return 0 (mem allocation failure is a real runtime condition, hence it shouldn't handled via asserts), I then crash in FoldingSetNode: 0 lli 0x0000000000a460ef 1 lli 0x0000000000a468fd 2 libpthread.so.0 0x0000003b3b00e990 3 lli 0x0000000000a264cb llvm::FoldingSetImpl::InsertNode(llvm::FoldingSetImpl::Node, void) + 43 4 lli 0x0000000000907067 llvm::ScalarEvolution::getUnknown(llvm::Value*) + 327 5 lli 0x00000000008809ef