[squeak-dev] Alien & Squeak FFI issues on Snow Leopard.

John M McIntosh johnmci at smalltalkconsulting.com
Wed Sep 30 02:13:22 UTC 2009


Someone finally managed to fire up a Sophie app http://www.opensophie.org/ 
  on Snow Leopard and immediately found an issue that also affects  
Squeak users who do fascinating things with FFI
The innocent FFI call was

apifstat: afileNo statBuffer: buffer
	<cdecl: long 'fstat' (long MacStat* ) module: 'libc.dylib'>
	^self externalCallFailed

Now it seems BEFORE Snow Leopard *somehow* the Squeak external  
primitive call api which is part of the VM to assist in loading  
plugins or finding function entry points in executable binaries or  
libraries would
return the entry point for fstat by *somehow* finding libc.dylib which  
is via  /usr/lib/libc.dylib -> libSystem.dylib ->  libSystem.B.dylib

Interestingly this is found implicitly since the mac carbon vm lookup  
logic never looks in /usr/lib/

Now in Snow Leopard it seems they do less implicit searching, perhaps  
a security concern?  Then it fails.

In the past the Unix VM would search a hundred(sic) more places, but I  
understand less today, but it might still work? Maybe /usr/lib is in  
the hit list?

This issue also applies to Alien because it calls back to the VM for  
it to find the module and function entry point.

Since I have received a request to ensure that doing an explicit full  
path should be allowed in the squeak carbon macintosh vm.
Then a change would be:

apifstat: afileNo statBuffer: buffer
	<cdecl: long 'fstat' (long MacStat* ) module: '/usr/lib/libc.dylib'>
	^self externalCallFailed

I'll look at doing this shortly.

However the workaround is to go to Sophie.app/Contents/Resources
and do a ln -s /usr/lib/libc.dylib libc.dylib
to create a symbolic link in the Resources directory for libc.dylib  
since we do explicitly look for libc.dylib in the Resources directory.

Obviously if you have a FFI call like above where you are calling a  
system library Oracle? for example.
You might find it no longer works with Snow Leopard on the Macintosh,  
so you should check.


--
= 
= 
= 
========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com>   Twitter:   
squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
= 
= 
= 
========================================================================







More information about the Squeak-dev mailing list