Is GCC 4.0 incompatible with Ruby on OS X (and elsewhere)?
Posted by David December 22, 2005 @ 08:42 PM
We’ve been receiving various reports of intermittent errors while running Rails applications and regular Ruby stuff that goes something like this: “undefined method ‘include?’ for -517611318:Fixnum”.
It appears that this might be a problem with GCC 4.0-compilations of Ruby. Most platforms are still using GCC 3.3, so they don’t see the problem. But on OS X, GCC 4.0 is now default if you’ve installed the recent Xcode. To switch back to GCC 3.3, do: sudo gcc_select 3.3 and then recompile Ruby.
We’ve love to get more reports and evidence on what exactly the problem is. Perhaps we can get it fixed in time for Ruby 1.8.4. Please use the comments.

That certainly seems to be the case in my instance. I’m running GCC 4.0.1 and I get intermittent errors just as you indicate. SwitchTower also seems to hang for me whereas it doesn’t for others; the only difference: GCC 4x.
I’ve experienced the same thing; I’ve had it break in various places, with the one that I can remember being ‘code_generation.rb’. This started after recompiling Ruby by hand, using GCC 4.0.1; my previous installation was via darwinports, when I had GCC 3.3 selected.
The best thing to do is find a succinct reproducible test case. The current best is a two-file DRb version, but it may take some time to trigger the fault.
GCC4 has not been found to be the root cause of the problems James Edward Gray II first brought this up and has reported that using GCC 3.3 on PPC did not make the problem completely go away.
Instead, it seems to be PPC-specific. Guy Decoux could not reproduce the problem on x86 with GCC4 but was able to reproduce it on PPC. He is unsure how to fix it and probably needs a more succinct testcase than the two-file DRb one.
For reference, see:
http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/165935?165771-168359+split-mode-vertical
http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-core/6826?6721-6978+split-mode-vertical
I had this problem previously too. The machine in question had been upgraded from Panther to Tiger, and I’d rebuilt Ruby using the then current version of XCode.
I had to rebuild Ruby from source on 10.4 after a hard drive failure and have not had this issue since. Using default gcc 4.0.0
I’ve seen a post about this before for the same thing, but instead it was like “-59450945:Fixnum”. If you notice, calling ”.id” on most objects returns a big number like this.
In my opinion, this is related to people calling ”.id” on ActiveRecord::Base objects, and getting just that, the object id.
Caleb
Is it possible that GCC 4.0 on OSX has moved to compiling 64-bit by default? I have problems with DRb with compiling 64-bit on SPARC, so maybe it’s related to byte sex.
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/153006
I’ve seen this same problem before but only in development mode on OS X Client with GCC 4.0.1.
I deploy (four sites) to an Xserve running Mac OS X Server 10.4.3 with GCC 4.0 and have never seen it there.
HTH.
Update, just tried to install SwitchTower and got this:
...snip…
Successfully installed switchtower-0.9.0 Successfully installed net-ssh-1.0.3 Successfully installed needle-1.2.1 Installing RDoc documentation for net-ssh-1.0.3…
lib/net/ssh/transport/ossl/hmac/services.rb:31:63: Skipping require of dynamic string: “net/ssh/transport/ossl/hmac/#{name}”
RDoc failure in lib/net/ssh/util/buffer.rb at or around line 147 column 1
...snip…
The internal error was:
ERROR: While executing gem … (NoMethodError) undefined method `match_io’ for -517611318:Fixnum
Caleb: Object ids are always positive integers since a VALUE is an unsigned int. Also, this occurs outside of Rails entirely, so people aren’t calling #id on non-AR objects.
Eric:
irb(main):002:0> a = “6908340963” => “6908340963” irb(main):003:0> a.id (irb):3: warning: Object#id will be deprecated; use Object#object_id => -606824140
I ran across this on the GMP homepage; may be relevant. May it’s worth trying gcc 4.0.1 on OSX to see if the problem persists?
http://www.swox.com/gmp/
GMP is very often miscompiled! We are seeing ever increasing problems with mis-compilations of the GMP code. Please never use your newly compiled libgmp.a or libgmp.so without first running make check. If it doesn’t run without errors, don’t trust the library, and please report this as a bug to the gmp-bugs@swox.com list, so that we can investigate it and make sure the bug is indeed in the compiler. (The compilers that cause problems are HP’s unbundled compilers and GCC, in particular Apple’s GCC releases. It has come to the point where a new compiler can be expected to miscompile GMP.)
As an example, of the 5 platforms where we’ve tried GCC 4.0.0, GCC doesn’t build on two platforms, and miscompiles GMP on the other three platforms. The GCC 3.4 series also had major problems, while the GCC 3.3 series worked somewhat better.
The GMP team deals with compiler bugs by having configure choose working optimization options, by changing the GMP code, and by rejecting hopeless compilers. But we cannot keep up with the GCC releases, which makes using a new GCC for compiling GMP quite risky. The GMP testsuite has great coverage, but it is not perfect, which means a make check isn’t a guarantee. To increase the likelyhood that you get a working libgmp, we recommend that you use a GCC released well before the GMP release you are compiling. Then we will have had a chance to implement workarounds.
For GMP 4.1.4, we recommend that you use GCC 3.3.x or older. We’ve had some luck with GCC 3.4.x on some systems, but we have yet to find a system where GCC 4.0.0 builds, and neither crashes or miscompiles the GMP sources.
UPDATE: We’ve had much more luck with GCC 4.0.1. It might actually be a usable compiler, but the usual care should be applied.
I’ve never encountered this problem on my PowerMac G5 and I’ve been using GCC 4 (and now 4.0.1 via XCode 2.2) all along. Tonight I built Ruby 1.8.4p3 for my PowerBook G4 and hit it right away installing Rails from gems:
Installing RDoc documentation for rake-0.6.2… ERROR: While executing gem … (NoMethodError) undefined method `each’ for -517611318:Fixnum
Could it be a G4-specific problem?
I too have had the problem with “-59450945:Fixnum” when using GCC 4.0.0 and ruby 1.8.3.
What seemed to fix it for me was using this configuration when compiling ruby:
./configure \ --prefix=/usr/local \ --disable-fat-binary \ --enable-frame-address \ --enable-largefile \ --enable-pthread \ --enable-shared \ --enable-install-docUsing this configure fixed the problem for me. I no longer have any issues running ruby 1.8.3 on OS X.
I had previous versions of ruby 1.8.3 compiled using these flags and was experiencing the problem:
./configure \ --prefix=/usr/local \ --enable-pthread \ --enable-shared \ --enable-install-docSo one or a combination of these flags fixes the problem:
--disable-fat-binary --enable-frame-address --enable-largefileI too have had the problem with “-59450945:Fixnum” when using GCC 4.0.0 and ruby 1.8.3.
What seemed to fix it for me was using this configuration when compiling ruby:
./configure —prefix=/usr/local —disable-fat-binary —enable-frame-address —enable-largefile —enable-pthread —enable-shared —enable-install-doc
Using this configure fixed the problem for me. I no longer have any issues running ruby 1.8.3 on OS X.
I had previous versions of ruby 1.8.3 compiled using these flags and was experiencing the problem:
./configure —prefix=/usr/local —enable-pthread —enable-shared —enable-install-doc
So one or a combination of these flags fixes the problem:
Mark: Good suggestion but I don’t think it’s just a G4 problem. I’ve hit it on a Dual 1.8 G5.
Jonathon: The only option that would be doing something out of the three you mention is—enable-frame-pointer. I tried rebuilding Ruby with it, but now things just blow up differently doing a gem install rails>
Installing RDoc documentation for activerecord-1.13.2... SLex::Detail: op3: ERROR: While executing gem ... (NoMethodError) undefined method `text' for -517611318:FixnumAnon: Damn. My Dual 1.8 has been problem free whereas I keep hitting these problems all the time on the PowerBook.
HOLY COW!
I’ve been getting this error intermittently, but not on Mac OS X, and not with 1.8.4.
I’ve been getting this error on Debian Sarge’s ruby (which is 1.8.2++), and I assume has been compiled with gcc < 4.0.
IT’S BEEN DRIVING ME CRAZY!
I haven’t noticed the problem as much when running with 1.8.4-preview2 compiled with gcc 3.3 (though, it seems to have other issues).
I hope someone looks into this a bit more thoroughly. Following ps output for the ruby process, and hitting the front page of my app regularly, it seems that these errors happen concurrently with a memory allocation, and they seem to not happen when I manually, aggressivley garbage-collect in an after_filter.
I’m not quite sure what that means, but hopefully it’ll be a clue to someone.
I can say definitively that—enable-frame-address has fixed my system after seeing every problem in this thread in 30 mins… my guess… http://developer.apple.com/documentation/Darwin/Conceptual/64bitPorting/index.html
scratch that…