Author Topic: g++ Segmentation fault ?  (Read 685 times)

LeoTh3o

  • Full Member
  • ***
  • Posts: 231
  • Reputation: 43
    • ET&C
  • Computers: MacBook Pro 15', half 2009, OS X 10.8.1
  • iDevices: iPod 3G iOS 5.1.1; iPad 2 WiFi iOS 5.1.1 jb
g++ Segmentation fault ?
« on: September 04, 2012, 05:19:03 am »
While trying to build llvm I got this error:

Segmentation fault: 11  g++ -I/private/var/root/build/sub/build/lib/Target/ARM/AsmParser/.. -I/private/var/root/build/sub/llvm/lib/Target/ARM/AsmParser/.. -I/private/var/root/build/sub/build/include -I/private/var/root/build/sub/build/lib/Target/ARM/AsmParser -I/private/var/root/build/sub/llvm/include -I/private/var/root/build/sub/llvm/lib/Target/ARM/AsmParser -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O3 -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fno-common -Woverloaded-virtual -Wcast-qual -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -c -MMD -MP -MF "/private/var/root/build/sub/build/lib/Target/ARM/AsmParser/Release+Asserts/ARMAsmParser.d.tmp" -MT "/private/var/root/build/sub/build/lib/Target/ARM/AsmParser/Release+Asserts/ARMAsmParser.o" -MT "/private/var/root/build/sub/build/lib/Target/ARM/AsmParser/Release+Asserts/ARMAsmParser.d" /private/var/root/build/sub/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp -o /private/var/root/build/sub/build/lib/Target/ARM/AsmParser/Release+Asserts/ARMAsmParser.o
/bin/sh: line 1:   776 Segmentation fault: 11  ( make -C $dir all )


I didn't know there could be a segfault from just building software and I already know gcc works.
0xEB        0xFE
jmp short -2

Trcx528

  • Haxor
  • Hero Member
  • *****
  • Posts: 4502
  • Reputation: 166
  • Google it!
    • iNinjas
  • Badges:
  • Computers: 13" 2011 Macbook Pro, 120 GB SSD and 16 GB of Ram
  • iDevices: None
Re: g++ Segmentation fault ?
« Reply #1 on: September 04, 2012, 09:49:14 am »
Hmm, first we need to identify what is segfaulting....I'm guessing make, but I am not sure.  Not sure how to validate that is the case though. 

LeoTh3o

  • Full Member
  • ***
  • Posts: 231
  • Reputation: 43
    • ET&C
  • Computers: MacBook Pro 15', half 2009, OS X 10.8.1
  • iDevices: iPod 3G iOS 5.1.1; iPad 2 WiFi iOS 5.1.1 jb
Re: g++ Segmentation fault ?
« Reply #2 on: September 05, 2012, 04:23:10 am »
According to google, there has been an identical error on a crosscompiler for pandorabox. it's g++'s fault, anyway. The solution proposed is to change the compiler.
0xEB        0xFE
jmp short -2

Trcx528

  • Haxor
  • Hero Member
  • *****
  • Posts: 4502
  • Reputation: 166
  • Google it!
    • iNinjas
  • Badges:
  • Computers: 13" 2011 Macbook Pro, 120 GB SSD and 16 GB of Ram
  • iDevices: None
Re: g++ Segmentation fault ?
« Reply #3 on: September 05, 2012, 08:21:01 am »
Figures, perhaphs it would be worth while to port a different compiler, tcc or something, just for problems like this.  Of course we should check that against supported compilers. 

LeoTh3o

  • Full Member
  • ***
  • Posts: 231
  • Reputation: 43
    • ET&C
  • Computers: MacBook Pro 15', half 2009, OS X 10.8.1
  • iDevices: iPod 3G iOS 5.1.1; iPad 2 WiFi iOS 5.1.1 jb
Re: g++ Segmentation fault ?
« Reply #4 on: September 08, 2012, 05:28:50 am »
I failed in trying to get a build of clang crosscompiling it via javacom's toolchain4. The fail is at the build-tools phase (the first stem for those who dared building a compiler. It's intended to create some needed utils, such as llvm-tblgen, or cgcc in gcc's case).


I'd like to add that I got the set fault above when trying to build clang on an iPad2 while using dynamic_page. I had to as the build of some files would exceed the amount of ram available, killing gcc before it could create the output. If someone has a newer/bett device, he/she might give a try and see how far can go. I suggest connecting the device via USB and using iPhoneTunnel or apps alike to spare some more ram (a wifi/direct ssh would use much more ram than this way).

edit: on the use of currently built clang: one of my guesses lead me to think that clang needs a flag to know what architecture it has to build. According to llvm-config --targets-built, there are more than one.
clang DO NOT accept the -arch flag. In its place -ccc-host-triple armv7-apple-darwin11 should be used (this one was an example). Even with this new info I can't get it to build without having the undefined symbol dyld_stub_ binding_helper


edit 2: Be sure to specify armv[67] as the simple arm build for architecture armv4t.
« Last Edit: September 08, 2012, 10:36:15 am by LeoTh3o »
0xEB        0xFE
jmp short -2

Don't like seeing ads? Click here to register!

LeoTh3o

  • Full Member
  • ***
  • Posts: 231
  • Reputation: 43
    • ET&C
  • Computers: MacBook Pro 15', half 2009, OS X 10.8.1
  • iDevices: iPod 3G iOS 5.1.1; iPad 2 WiFi iOS 5.1.1 jb
Re: g++ Segmentation fault ?
« Reply #5 on: September 09, 2012, 11:02:03 am »
As of today 09/09/12, I have built both clang and llvm. The result obtained from this compiler is the same as the "old" clang: execution of the binaries fail with error 11 (SIGSYS).

I'll try rebuilding gcc, Saurik's way, on iOS.
0xEB        0xFE
jmp short -2

LeoTh3o

  • Full Member
  • ***
  • Posts: 231
  • Reputation: 43
    • ET&C
  • Computers: MacBook Pro 15', half 2009, OS X 10.8.1
  • iDevices: iPod 3G iOS 5.1.1; iPad 2 WiFi iOS 5.1.1 jb
Re: g++ Segmentation fault ?
« Reply #6 on: September 15, 2012, 09:22:23 am »
edit: on the use of currently built clang: one of my guesses lead me to think that clang needs a flag to know what architecture it has to build. According to llvm-config --targets-built, there are more than one.
clang DO NOT accept the -arch flag. In its place -ccc-host-triple armv7-apple-darwin11 should be used (this one was an example). Even with this new info I can't get it to build without having the undefined symbol dyld_stub_ binding_helper

edit 2: Be sure to specify armv[67] as the simple arm build for architecture armv4t.

According to my (little) understanding of this and this and the verbose output of clang, by default it targets "-triple armv4t-apple-macosx10.7.0", while "-triple armv7-apple-macosx10.7.0" is needed.
0xEB        0xFE
jmp short -2

Trcx528

  • Haxor
  • Hero Member
  • *****
  • Posts: 4502
  • Reputation: 166
  • Google it!
    • iNinjas
  • Badges:
  • Computers: 13" 2011 Macbook Pro, 120 GB SSD and 16 GB of Ram
  • iDevices: None
Re: g++ Segmentation fault ?
« Reply #7 on: September 15, 2012, 12:11:26 pm »
so is it working now?

LeoTh3o

  • Full Member
  • ***
  • Posts: 231
  • Reputation: 43
    • ET&C
  • Computers: MacBook Pro 15', half 2009, OS X 10.8.1
  • iDevices: iPod 3G iOS 5.1.1; iPad 2 WiFi iOS 5.1.1 jb
Re: g++ Segmentation fault ?
« Reply #8 on: September 16, 2012, 12:38:10 pm »
it works, but I haven't tested it in building binary programs yet.
0xEB        0xFE
jmp short -2

LeoTh3o

  • Full Member
  • ***
  • Posts: 231
  • Reputation: 43
    • ET&C
  • Computers: MacBook Pro 15', half 2009, OS X 10.8.1
  • iDevices: iPod 3G iOS 5.1.1; iPad 2 WiFi iOS 5.1.1 jb
Re: g++ Segmentation fault ?
« Reply #9 on: September 21, 2012, 08:39:20 am »
Little note on my previous edit: the -target cannot be used directly. You still need -ccc-host-triple, which clang will consider later as -target. It's a bit complicated and I don't have a clear idea.
-target, anyway, is not accepted as that (I think it accepted it since I had other things specified).

Bye for now.
0xEB        0xFE
jmp short -2

Don't like seeing ads? Click here to register!