Man, sometimes I feel really dumb.

So I’m trying to fix a bug in some old C code, where I want to add the ability to bind to a specific IP instead of INADDR_ANY. This is on my Apple laptop, which has the latest Apple Xcode (3.1) build on it. Oddly, the C compiler starts spewing bizarro error messages on code that I’m pretty sure is valid. So I backtrack, download Xcode 3.0 (gigs!), and that compiles it OK.

But the binary segfaults when you run it! So now I don’t have a working compiler. This is a problem for a code monkey…

Today, I tried again:

  • Code builds and runs on Linux
  • Download latest Xcode 3.1 from Apple, install.
  • Compile fails.
  • Go digging around hard drive, find copy of hello.c I have parked. (Yes, real nerds keep ‘hello world’ saved, in several languages, for just such occasions as this!)
  • Compile hello.c:

cc hello.c
/var/folders/Sw/SwEOWKQ7FdihT03Yr5CBOU+++TI/-Tmp-//ccNBFXHP.s:15:section difference divide by two expression, "LC0" minus "L00000000001$pb" divide by 2 will not produce an assembly time constant

Well. Same errors as my code, though only one of them. It’s not (prolly) libraries, so WTF? Guess I’m off to flog the DSL downloading Xcode 3.0. Man, this sucks. Fink? Something else I’ve installed? No luck googling the error, oddly. Since I’m pretty sure others would’ve noticed a broken C compiler, it’s probably my problem. Crap.

Update 8/18/08: See Per Mildner’s comment - the secret is MallocScribble. 

3 Responses to “Man, sometimes I feel really dumb.”

  1. Terri Says:

    `Twas brillig, and the slithy toves
    Did gyre and gimble in the wabe:
    All mimsy were the borogoves,
    And the mome raths outgrabe.

    “Beware the Jabberwock, my son!
    The jaws that bite, the claws that catch!
    Beware the Jubjub bird, and shun
    The frumious Bandersnatch!”

    He took his vorpal sword in hand:
    Long time the manxome foe he sought –
    So rested he by the Tumtum tree,
    And stood awhile in thought.

    And, as in uffish thought he stood,
    The Jabberwock, with eyes of flame,
    Came whiffling through the tulgey wood,
    And burbled as it came!

    One, two! One, two! And through and through
    The vorpal blade went snicker-snack!
    He left it dead, and with its head
    He went galumphing back.

    “And, has thou slain the Jabberwock?
    Come to my arms, my beamish boy!
    O frabjous day! Callooh! Callay!’
    He chortled in his joy.

    `Twas brillig, and the slithy toves
    Did gyre and gimble in the wabe;
    All mimsy were the borogoves,
    And the mome raths outgrabe.

    ********************
    Yes, the above is JABBERWOCKY
    by Lewis Carroll (from Through the Looking-Glass and What Alice Found There, 1872)

  2. Per Mildner Says:

    Are you using MallocScribble?

    I get the exact same problem after upgrading to XCode 3.1. I am building from the command line using gcc-4.2. The problem seems to be caused by having set MallocScribble=1 in the environment. To reproduce run gcc something like
    env MallocScribble=1 gcc-4.2 -c helloworld.c
    To suppress it do something like:
    ( unset MallocScribble; gcc-4.2 -c helloworld.c )

    This is probably a problem with ‘as’ since the same symptoms happens for gcc-4.2, gcc-4.0, llvm-gcc-4.2

    MallocScribble has exposed bugs in the XCode tools before. Some older version of XCode (Perhaps 3.0) had a bug that crashed ‘ld’ when MallocScribble was used.

    If MallocScribble is required for this to happen then that may explain why your page is the only google hit for this issue.

  3. Paul Says:

    Yep, that’s it! Oh, thankyouthankyou!!!

Leave a Reply