llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

internal compiler error when building firefox: nsMemoryImpl.cpp

Open tkremenek opened this issue 20 years ago • 12 comments

Bugzilla Link 1008
Resolution FIXED
Resolved on Mar 06, 2010 14:00
Version 1.9
OS MacOS X
Attachments preprocessed cpp file that triggers bug

Extended Description

llvm-g++ triggers an internal compiler error when trying to compile nsMemoryImpl.cpp:

llvm-g++ -o nsMemoryImpl.o -c -DMOZILLA_INTERNAL_API -DOSTYPE="Darwin" -DOSARCH="Darwin" -DBUILD_ID=0000000000 -D_IMPL_NS_COM -I../../dist/include/string -I../../dist/include/xpcom -I../../dist/include -I../../dist/include/nspr -I/usr/X11R6/include -fPIC -I/usr/X11R6/include -fno-rtti -fno-exceptions -Wall -Wconversion -Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wno-long-long -fpascal-strings -no-cpp-precomp -fno-common -fshort-wchar -I/Developer/Headers/FlatCarbon -DNDEBUG -DTRIMMED -O2 -I/usr/X11R6/include -DMOZILLA_CLIENT -include ../../mozilla-config.h -Wp,-MD,.deps/nsMemoryImpl.pp /Users/kremenek/build/firefox/mozilla/xpcom/base/nsMemoryImpl.cpp /Users/kremenek/build/firefox/mozilla/xpcom/base/nsMemoryImpl.cpp: In function 'void* NS_Realloc_P(void*, PRSize)': /Users/kremenek/build/firefox/mozilla/xpcom/base/nsMemoryImpl.cpp:346: internal compiler error: Bus error Please submit a full bug report, with preprocessed source if appropriate. See URL:http://llvm.org/bugs for instructions.

tkremenek avatar Nov 17 '06 07:11 tkremenek

Here is the llvm-gcc patch.

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20061113/040049.html

llvmbot avatar Nov 17 '06 21:11 llvmbot

Great, please include a link to the patch in case Ted wants to rebuild llvm-gcc before the mirror updates, thanks!

-Chris

lattner avatar Nov 17 '06 21:11 lattner

Fixed.

llvmbot avatar Nov 17 '06 21:11 llvmbot

This happens even when -fpascal-strings is not used. Here is the backtrace ...

(gdb) where #​0 0x90069084 in __kill () #​1 0x900b8ce8 in abort () #​2 0x900bdc10 in __assert_rtn () #​3 0x0078fff0 in TreeConstantToLLVM::ConvertSTRING_CST (exp=0x1bc9840) at ../../llvm- gcc/gcc/llvm-convert.cpp:4152 #​4 0x0079024c in TreeConstantToLLVM::EmitLV_STRING_CST (exp=0x1bc9840) at ../../llvm- gcc/gcc/llvm-convert.cpp:4718 #​5 0x007957c8 in TreeToLLVM::EmitLV (this=0xbfffed54, exp=0x1bc9840) at ../../llvm- gcc/gcc/llvm-convert.cpp:632 #​6 0x00797e94 in TreeToLLVM::EmitADDR_EXPR (this=0xbfffed54, exp=0x1be2f60) at ../../llvm- gcc/gcc/llvm-convert.cpp:1740 #​7 0x00794a9c in TreeToLLVM::Emit (this=0xbfffed54, exp=0x1be2f60, DestLoc=0x0) at ../../llvm- gcc/gcc/llvm-convert.cpp:515 #​8 0x007aa854 in TreeToLLVM::EmitNOP_EXPR (this=0xbfffed54, exp=0x1be2fc0, DestLoc=0x0) at ../../llvm-gcc/gcc/llvm-convert.cpp:2139 #​9 0x00794b08 in TreeToLLVM::Emit (this=0xbfffed54, exp=0x1be2fc0, DestLoc=0x0) at ../../llvm- gcc/gcc/llvm-convert.cpp:521 #​10 0x007ba318 in TreeToLLVM::EmitMODIFY_EXPR (this=0xbfffed54, exp=0x1be59c0, DestLoc=0x0) at ../../llvm-gcc/gcc/llvm-convert.cpp:2054 #​11 0x00794ad4 in TreeToLLVM::Emit (this=0xbfffed54, exp=0x1be59c0, DestLoc=0x0) at ../../llvm- gcc/gcc/llvm-convert.cpp:517 #​12 0x007b5920 in TreeToLLVM::EmitSTATEMENT_LIST (this=0xbfffed54, exp=0x1be3260, DestLoc=0x0) at ../../llvm-gcc/gcc/llvm-convert.cpp:1189 #​13 0x007949bc in TreeToLLVM::Emit (this=0xbfffed54, exp=0x1be3260, DestLoc=0x0) at ../../llvm- gcc/gcc/llvm-convert.cpp:490 #​14 0x007b4d64 in TreeToLLVM::EmitCOND_EXPR (this=0xbfffed54, exp=0x1be5930) at ../../llvm- gcc/gcc/llvm-convert.cpp:1370 #​15 0x00794a20 in TreeToLLVM::Emit (this=0xbfffed54, exp=0x1be5930, DestLoc=0x0) at ../../llvm- gcc/gcc/llvm-convert.cpp:496 #​16 0x007b5920 in TreeToLLVM::EmitSTATEMENT_LIST (this=0xbfffed54, exp=0x1be32a0, DestLoc=0x0) at ../../llvm-gcc/gcc/llvm-convert.cpp:1189 #​17 0x007949bc in TreeToLLVM::Emit (this=0xbfffed54, exp=0x1be32a0, DestLoc=0x0) at ../../llvm- gcc/gcc/llvm-convert.cpp:490 #​18 0x007b7324 in TreeToLLVM::EmitBIND_EXPR (this=0xbfffed54, exp=0x1be5810, DestLoc=0x0) at ../../llvm-gcc/gcc/llvm-convert.cpp:1164 #​19 0x007949a0 in TreeToLLVM::Emit (this=0xbfffed54, exp=0x1be5810, DestLoc=0x0) at ../../llvm- gcc/gcc/llvm-convert.cpp:489 #​20 0x007b5920 in TreeToLLVM::EmitSTATEMENT_LIST (this=0xbfffed54, exp=0x1be33c0, DestLoc=0x0) at ../../llvm-gcc/gcc/llvm-convert.cpp:1189 #​21 0x007949bc in TreeToLLVM::Emit (this=0xbfffed54, exp=0x1be33c0, DestLoc=0x0) at ../../llvm- gcc/gcc/llvm-convert.cpp:490 #​22 0x007b7324 in TreeToLLVM::EmitBIND_EXPR (this=0xbfffed54, exp=0x1be5870, DestLoc=0x0) at ../../llvm-gcc/gcc/llvm-convert.cpp:1164 #​23 0x007949a0 in TreeToLLVM::Emit (this=0xbfffed54, exp=0x1be5870, DestLoc=0x0) at ../../llvm- gcc/gcc/llvm-convert.cpp:489 #​24 0x0077e914 in llvm_emit_code_for_current_function (fndecl=0x46ee3b80) at ../../llvm- gcc/gcc/llvm-backend.cpp:418 #​25 0x002f0854 in tree_rest_of_compilation (fndecl=0x46ee3b80) at ../../llvm-gcc/gcc/tree- optimize.c:704 #​26 0x001c9840 in expand_body (fn=0x46ee3b80) at ../../llvm-gcc/gcc/cp/semantics.c:3006 #​27 0x008278b0 in cgraph_expand_function (node=0x1b52400) at ../../llvm- gcc/gcc/cgraphunit.c:896 #​28 0x0082a9d4 in cgraph_expand_all_functions () at ../../llvm-gcc/gcc/cgraphunit.c:1812 #​29 0x0082ae8c in cgraph_optimize () at ../../llvm-gcc/gcc/cgraphunit.c:1909 #​30 0x0011565c in cp_finish_file () at ../../llvm-gcc/gcc/cp/decl2.c:3126 #​31 0x00003670 in finish_file () at ../../llvm-gcc/gcc/cp/cp-lang.c:113 #​32 0x00294ff0 in c_common_parse_file (set_yydebug=0) at ../../llvm-gcc/gcc/c-opts.c:1239 #​33 0x00715224 in compile_file () at ../../llvm-gcc/gcc/toplev.c:1100 #​34 0x00718418 in do_compile () at ../../llvm-gcc/gcc/toplev.c:2327 #​35 0x007184b8 in toplev_main (argc=46, argv=0xbffff44c) at ../../llvm-gcc/gcc/toplev.c:2359 #​36 0x002ada98 in main (argc=46, argv=0xbffff44c) at ../../llvm-gcc/gcc/llvm-main.cpp:37

llvmbot avatar Nov 17 '06 21:11 llvmbot

I'm pretty sure that -fpascal-strings isn't available in normal FSF builds: the GCC's on my linux box don't appear to have it, and I don't think that patch ever was committed.

In any case, thanks for taking a look at this Reid.

lattner avatar Nov 17 '06 20:11 lattner

There are many APPLE LOCAL patches that are not darwin specific. See, http://gcc.gnu.org/ml/gcc-patches/2001-07/msg00323.html

For example, #pragma support to enable/disable optimization :)

llvmbot avatar Nov 17 '06 09:11 llvmbot

Okay, it hasn't been ages, but it has been 5 years. It seems like so much longer.

http://gcc.gnu.org/ml/gcc-patches/2001-07/msg00200.html

The patch (for -fpascal-strings) doesn't seem to be Darwin specific.

Reid.

llvmbot avatar Nov 17 '06 09:11 llvmbot

Yup, pascal-strings is APPLE LOCAL.

llvmbot avatar Nov 17 '06 09:11 llvmbot

You're joking, right?

lattner avatar Nov 17 '06 08:11 lattner

I would doubt that. GCC has had -fpascal-strings for ages.

llvmbot avatar Nov 17 '06 08:11 llvmbot

-fpascal-strings is probably a darwin-specific option. Devang, can you investigate please?

-Chris

lattner avatar Nov 17 '06 08:11 lattner

This problem is due to the use of the -fpascal-strings option which llvm-gcc4 doesn't handle. The internal compiler error is not a crash, its an abort() call at opts.c:1194:

default:
  /* If the flag was handled in a standard way, assume the lack of
     processing here is intentional.  */
  /* APPLE LOCAL optimization pragmas 3124235/3420242 */
  if (cl_options[scode].flag_var || cl_options[scode].access_flag)
    break;

  abort ();  /* <<<<< */

I tried running it without the -fpascal-strings option, but then it won't compile:

../../dist/include/xpcom/nsAutoLock.h:183: error: 'operator new' takes type 'size_t' ('unsigned int') as first parameter ../../dist/include/xpcom/nsAutoLock.h:343: error: 'operator new' takes type 'size_t' ('unsigned int') as first parameter ../../dist/include/xpcom/nsAutoLock.h:410: error: 'operator new' takes type 'size_t' ('unsigned int') as first parameter /usr/include/c++/4.0.0/new:84: error: 'operator new' takes type 'size_t' ('unsigned int') as first parameter /usr/include/c++/4.0.0/new:85: error: 'operator new' takes type 'size_t' ('unsigned int') as first parameter /usr/include/c++/4.0.0/new:88: error: 'operator new' takes type 'size_t' ('unsigned int') as first parameter /usr/include/c++/4.0.0/new:89: error: 'operator new' takes type 'size_t' ('unsigned int') as first parameter /usr/include/c++/4.0.0/new:94: error: 'operator new' takes type 'size_t' ('unsigned int') as first parameter /usr/include/c++/4.0.0/new:95: error: 'operator new' takes type 'size_t' ('unsigned int') as first parameter

Sorry, don't know what to tell you. llvm-gcc4 doesn't support that usage.

llvmbot avatar Nov 17 '06 08:11 llvmbot