Re: [sqlite] [PATCH] Fix "Symbol not found: _OSAtomicCompareAndSwapPtrBarrier" on Mac OS X 10.4 (Tiger)
On Tue, Aug 21, 2012 at 8:54 PM, Dwayne Litzenberger wrote: > Recent versions of SQLite fail to run on Mac OS X 10.4 (Tiger) with > the following error message: > We don't test SQLite in MacOS 10.4, but we do test every release on MacOS 10.2. For that platform, we add the compile-time option: -DSQLITE_WITHOUT_ZONEMALLOC Doing the same should clear the problem on MacOS 10.4 as well. And using that approach will save us from having to maintain a bunch of hard-to-test preprocessor logic. > > $ DYLD_LIBRARY_PATH=. ./sqlite3 > dyld: lazy symbol binding failed: Symbol not found: > _OSAtomicCompareAndSwapPtrBarrier > Referenced from: ./libsqlite3.0.dylib > Expected in: /usr/lib/libSystem.B.dylib > > dyld: Symbol not found: _OSAtomicCompareAndSwapPtrBarrier > Referenced from: ./libsqlite3.0.dylib > Expected in: /usr/lib/libSystem.B.dylib > > Trace/BPT trap > > This is because OSAtomicCompareAndSwapPtrBarrier was not introduced > until Mac OS X 10.5 (Leopard). > > Affected versions: > > - Latest trunk (fossil 45cdc32f1e cloned from https://sqlite.org/src/) > - SQLite 3.7.13 > - SQLite 3.7.12 > > Not affected: > > - SQLite 3.7.11 > - SQLite 3.7.10 > - SQLite 3.7.9 > > Build environment: > > Mac OS X SDK: MacOSX10.6.sdk > > $ xcodebuild -version > Xcode 3.2.5 > Component versions: DevToolsCore-1763.0; DevToolsSupport-1758.0 > BuildVersion: 10M2423 > > $ gcc --version > i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664) > > How to reproduce: > > I built SQLite on a Mac OS X 10.5 (Leopard) machine, then copied > .libs/ to a machine running 10.4 (Tiger) and ran sqlite3 from there: > > tar xzf sqlite-autoconf-3071300.tar.gz > mkdir bld > cd bld > CFLAGS='-arch ppc -arch i386 -mmacosx-version-min=10.4' \ > LDFLAGS='-arch ppc -arch i386 -mmacosx-version-min=10.4' \ > ../sqlite-autoconf-3071300/configure --without-dependency-tracking > make > rsync --delete -a .libs/ tigerbox:~/sqlite-scratch/ > ssh -t tigerbox "cd ~/sqlite-scratch && DYLD_LIBRARY_PATH=. ./sqlite3" > > I should get a regular sqlite prompt. What I actually got was the > "Symbol not found" error above. > > It looks like other people have seen this issue before[1], but it does > not look like it's actually been fixed. > > Please apply the attached patch against the latest trunk (45cdc32f1e), > which fixes this bug. (You can ignore the git commit id in the patch. > It wasn't obvious to me how to make fossil output a commit as a > patch, so just I did a "git init" inside the fossil working directory > and then worked from that.) > > Cheers, > - Dwayne > > [1] http://sqlite.org:8080/pipermail/sqlite-users/2012-January/036184.html > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] [PATCH] Fix "Symbol not found: _OSAtomicCompareAndSwapPtrBarrier" on Mac OS X 10.4 (Tiger)
On Tue, Aug 21, 2012 at 5:54 PM, Dwayne Litzenberger wrote: > Please apply the attached patch against the latest trunk (45cdc32f1e), > which fixes this bug. It looks like the mailman archives stripped the patch, so here it is again, as text: commit adf442e047fcf8523b43ff975be872a36e3d5b40 Author: Dwayne Litzenberger Date: Tue Aug 21 14:59:05 2012 -0700 Don't try to use OSAtomicCompareAndSwapPtrBarrier when building for Mac OS X 10.4 and earlier. OSAtomicCompareAndSwapPtrBarrier was introduced in Mac OS X 10.5, so we get a dyld error when starting on 10.4 if we build using a newer SDK. diff --git a/src/mem1.c b/src/mem1.c index 3578496..c42db01 100644 --- a/src/mem1.c +++ b/src/mem1.c @@ -68,6 +68,7 @@ #include #include #include +#include static malloc_zone_t* _sqliteZone_; #define SQLITE_MALLOC(x) malloc_zone_malloc(_sqliteZone_, (x)) #define SQLITE_FREE(x) malloc_zone_free(_sqliteZone_, (x)); @@ -235,8 +236,16 @@ static int sqlite3MemInit(void *NotUsed){ malloc_zone_t* newzone = malloc_create_zone(4096, 0); malloc_set_zone_name(newzone, "Sqlite_Heap"); do{ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone, (void * volatile *)&_sqliteZone_); +#elif defined(__LP64__) + success = OSAtomicCompareAndSwap64Barrier((int64_t)NULL, (int64_t)newzone, + (int64_t volatile *)&_sqliteZone_); +#else + success = OSAtomicCompareAndSwap32Barrier((int32_t)NULL, (int32_t)newzone, + (int32_t volatile *)&_sqliteZone_); +#endif }while(!_sqliteZone_); if( !success ){ /* somebody registered a zone first */ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users