[Ohrrpgce] FreeBASIC Mac OS X build

Ralph Versteegen teeemcee at gmail.com
Mon Oct 11 05:08:49 PDT 2010


On 9 October 2010 17:25, Ralph Versteegen <teeemcee at gmail.com> wrote:
> On 9 October 2010 14:00, James Paige <Bob at hamsterrepublic.com> wrote:
>>> Odd... why is the linker complaining? Also I'm surprised that it's
>>> symlinked to libSystem. Try
>>> file /usr/lib/libgcc_s.1.dylib
>>> to see the architectures included, and edit Makefile to add -v to
>>> FBFLAGS, and see what it passes to as.
>>> A desperate possibility for fix would be adding '-Wl -lgcc_s.10.4' to FBFLAGS
>>
>> So I got this working with -Wl -lgcc_s.10.4
>>
>> I created a symlink from ~/fw pointing to ~/Library/Frameworks and I
>> used that in my FRAMEWORKS_PATH and that made the command line short
>> enough that (freebasic?) didn't truncate it, and the build worked!
>>
>> That gives me ohrrpgce-game and ohrrpgce-custom, but when I tested
>> ohrrpgce-custom by opening Vikings of Midgard, I crashed like this:
>>
>> broaste:~/src/ohr/wip james$ ./ohrrpgce-custom
>> ohrrpgce-custom(49712,0xa0523500) malloc: *** error for object
>> 0xbfffcdd0: pointer being freed was not allocated
>> *** set a breakpoint in malloc_error_break to debug
>> ohrrpgce-custom(49712,0xa0523500) malloc: *** error for object
>> 0xbfffcd74: pointer being freed was not allocated
>> *** set a breakpoint in malloc_error_break to debug
>> ohrrpgce-custom(49712,0xa0523500) malloc: *** error for object
>> 0xbfffcdec: pointer being freed was not allocated
>> *** set a breakpoint in malloc_error_break to debug
>> Segmentation fault
>>
>> ohrrpgce-game crashes like this:
>>
>> broaste:~/src/ohr/wip james$ ./ohrrpgce-game
>> ohrrpgce-game(49758,0xa0523500) malloc: *** error for object 0x8b04c483:
>> pointer being freed was not allocated
>> *** set a breakpoint in malloc_error_break to debug
>> Bus error
>>
>> Here is what gdbgame.sh tells me:
>>
>> broaste:~/src/ohr/wip james$ ./gdbgame.sh
>> GNU gdb 6.3.50-20050815 (Apple version gdb-1469) (Wed May  5 04:36:56
>> UTC 2010)
>> Copyright 2004 Free Software Foundation, Inc.
>> GDB is free software, covered by the GNU General Public License, and you
>> are
>> welcome to change it and/or distribute copies of it under certain
>> conditions.
>> Type "show copying" to see the conditions.
>> There is absolutely no warranty for GDB.  Type "show warranty" for
>> details.
>> This GDB was configured as "x86_64-apple-darwin"...Reading symbols for
>> shared libraries ............ done
>>
>> warning: Trying to remove a section from the ordered section list that
>> did not exist at 0x1d8000.
>>
>> warning: Trying to remove a section from the ordered section list that
>> did not exist at 0x1d9000.
>>
>> Breakpoint 1 at 0x175441: file ../../libfb_exit.c, line 47.
>> Breakpoint 2 at 0x8b60a5
>> Breakpoint 3 at 0x9a0674
>> Running...
>> Reading symbols for shared libraries
>> .+++++++++++............................................................................................
>> done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> Reading symbols for shared libraries . done
>> ohrrpgce-game(49808,0xa0523500) malloc: *** error for object 0x8b04c483:
>> pointer being freed was not allocated
>> *** set a breakpoint in malloc_error_break to debug
>>
>> Program received signal EXC_BAD_ACCESS, Could not access memory.
>> Reason: KERN_PROTECTION_FAILURE at address: 0x001073dd
>> fb_StrDelete (str=0x1073dd) at ../../libfb_str_del.c:51
>> 51      ../../libfb_str_del.c: No such file or directory.
>>        in ../../libfb_str_del.c
>> misc/gdbcmds1.txt:13: Error in sourced command file:
>> Invalid type combination in equality test.
>> Dumping state
>> $1 = 0x0
>> $2 = <unknown type>
>> $3 = <unknown type>
>>  4                                 0x9504e13a in
>> semaphore_timedwait_signal_trap ()
>>  3                                 0x950739b2 in __workq_kernreturn ()
>>  2 "com.apple.libdispatch-manager" 0x95074922 in kevent ()
>> * 1 "com.apple.main-thread"         fb_StrDelete (str=0x1073dd) at
>> ../../libfb_str_del.c:51
>> #0  fb_StrDelete (str=0x1073dd) at ../../libfb_str_del.c:51
>> No locals.
>> #1  0x00111c75 in Gfx_backend_init ()
>> No symbol table info available.
>> #2  0x0010111a in FONT_UNLOAD ()
>> No symbol table info available.
>> #3  0x0010124f in FONT_CREATE_EDGED ()
>> No symbol table info available.
>> #4  0x00101ebf in SETFONT ()
>> No symbol table info available.
>> #5  0x0001698c in SDL_main ()
>> No symbol table info available.
>> #6  0x001aa59c in -[SDLMain applicationDidFinishLaunching:] ()
>> No symbol table info available.
>> #7  0x9496f1c3 in _nsnote_callback ()
>> No symbol table info available.
>> #8  0x93f433c3 in __CFXNotificationPost ()
>> No symbol table info available.
>> #9  0x93f42dca in _CFXNotificationPostNotification ()
>> No symbol table info available.
>> #10 0x94964090 in -[NSNotificationCenter
>> postNotificationName:object:userInfo:] ()
>> No symbol table info available.
>> #11 0x9497146d in -[NSNotificationCenter postNotificationName:object:]
>> ()
>> No symbol table info available.
>> #12 0x9131670a in -[NSApplication _postDidFinishNotification] ()
>> No symbol table info available.
>> #13 0x9131661a in -[NSApplication _sendFinishLaunchingNotification] ()
>> No symbol table info available.
>> #14 0x9146d6a9 in -[NSApplication(NSAppleEventHandling) _handleAEOpen:]
>> ()
>> No symbol table info available.
>> #15 0x9146d2c9 in -[NSApplication(NSAppleEventHandling)
>> _handleCoreEvent:withReplyEvent:] ()
>> No symbol table info available.
>> #16 0x949a4400 in -[NSAppleEventManager
>> dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()
>> No symbol table info available.
>> #17 0x949a41c4 in _NSAppleEventManagerGenericHandler ()
>> No symbol table info available.
>> #18 0x98a1af58 in aeDispatchAppleEvent ()
>> No symbol table info available.
>> #19 0x98a1ae57 in dispatchEventAndSendReply ()
>> No symbol table info available.
>> #20 0x98a1ad61 in aeProcessAppleEvent ()
>> No symbol table info available.
>> #21 0x97323323 in AEProcessAppleEvent ()
>> No symbol table info available.
>> #22 0x912e6cc6 in _DPSNextEvent ()
>> No symbol table info available.
>> #23 0x912e62ca in -[NSApplication
>> nextEventMatchingMask:untilDate:inMode:dequeue:] ()
>> No symbol table info available.
>> #24 0x912a855b in -[NSApplication run] ()
>> No symbol table info available.
>> #25 0x001aad46 in main ()
>> No symbol table info available.
>> (gdb)
>>
>>
>> ---
>> James
>
> fb_StrDelete's argument is equal to its return address. This is
> ambiguous; it could be either stack corruption inside fb_StrDelete
> (which I doubt) or bad emitted assembly causing a random jump to
> fb_StrDelete without setting up the stack. But I only ever saw this
> when cross-compiling with the broken version of gas on a Ubuntu
> install, and I provided the known-good gas build you're using. I'm not
> going to solve this anytime soon.
>
> Could you please email me ohrrpgce-game, ohrrpgce-custom, and the .o
> files? Hopefully I can reproduce it on Monday.
>
> OK, anyone else out there with a Mac willing to try: can you compile and run?
>

You didn't say when your build crashes, but for me it crashes when I
try to load a game, or to quit. I forgot how Game behaves.
Unfortunately I saw a very similar crash in one of my builds too.

I found that (at least one crash) is due to the wrong function being
called - the linker inserted the wrong function address. I have no
idea why this would happen. I think it was a garbage address into the
middle of a function. It wasn't even a "scattered" relocation.

I actually focused today on fixing the errors when creating a new
game, including the problem that Custom couldn't delete working.tmp.
Not at all as easy as I thought. Why on earth do we unlump twice (and
relump once) after creating a new RPG? Took me a while to realise
(largely because of start_new_debug problems). Equally confusing, gdb
doesn't show non-stack-aligned calls from FB to C properly, so I spent
a couple hours convinced that some crazy stack corruption was
occurring. It turns out that LOF leaves files positioned at the end (I
don't know why yet), so reading from lump files when lumping them
would result in zero-filled buffers, so when the new RPG file was
unlumped the second time archinym.lmp contains a bunch of zeroes so
Custom complains and inadvertently creates files named like .fnt so
killdir couldn't delete working.tmp because findfiles is a giant hack
and didn't find hidden files.

That's mostly fixed now, but feel free to tell me about how badly I
broke findfiles.



More information about the Ohrrpgce mailing list