psanford/sqlite3vfs

Is library support darwin?

le0pard opened this issue · 6 comments

Hello. Thanks for your great job and contrubution.

I did try to write own sqlite3vfs based on your library, but looks like in end it did not work on Apple.

First I did change Makefile by adding there -framework CoreFoundation -framework Security, because without this I had such error:

go build -tags SQLITE3VFS_LOADABLE_EXT -o donutloadable.a -buildmode=c-archive donut_loadable.go
rm donutloadable.h
gcc -g -fPIC -shared -o donutdb.so donutloadable.c donutloadable.a
Undefined symbols for architecture arm64:
  "_CFArrayAppendValue", referenced from:
      _crypto/x509/internal/macos.x509_CFArrayAppendValue_trampoline.abi0 in donutloadable.a(go.o)
  "_CFArrayCreateMutable", referenced from:
      _crypto/x509/internal/macos.x509_CFArrayCreateMutable_trampoline.abi0 in donutloadable.a(go.o)
  "_CFArrayGetCount", referenced from:
      _crypto/x509/internal/macos.x509_CFArrayGetCount_trampoline.abi0 in donutloadable.a(go.o)
  "_CFArrayGetValueAtIndex", referenced from:
      _crypto/x509/internal/macos.x509_CFArrayGetValueAtIndex_trampoline.abi0 in donutloadable.a(go.o)
  "_CFDataCreate", referenced from:
      _crypto/x509/internal/macos.x509_CFDataCreate_trampoline.abi0 in donutloadable.a(go.o)
  "_CFDataGetBytePtr", referenced from:
      _crypto/x509/internal/macos.x509_CFDataGetBytePtr_trampoline.abi0 in donutloadable.a(go.o)
  "_CFDataGetLength", referenced from:
      _crypto/x509/internal/macos.x509_CFDataGetLength_trampoline.abi0 in donutloadable.a(go.o)
  "_CFDateCreate", referenced from:
      _crypto/x509/internal/macos.x509_CFDateCreate_trampoline.abi0 in donutloadable.a(go.o)
  "_CFErrorCopyDescription", referenced from:
      _crypto/x509/internal/macos.x509_CFErrorCopyDescription_trampoline.abi0 in donutloadable.a(go.o)
  "_CFRelease", referenced from:
      _crypto/x509/internal/macos.x509_CFRelease_trampoline.abi0 in donutloadable.a(go.o)
  "_CFStringCreateExternalRepresentation", referenced from:
      _crypto/x509/internal/macos.x509_CFStringCreateExternalRepresentation_trampoline.abi0 in donutloadable.a(go.o)
  "_CFStringCreateWithBytes", referenced from:
      _crypto/x509/internal/macos.x509_CFStringCreateWithBytes_trampoline.abi0 in donutloadable.a(go.o)
  "_SecCertificateCopyData", referenced from:
      _crypto/x509/internal/macos.x509_SecCertificateCopyData_trampoline.abi0 in donutloadable.a(go.o)
  "_SecCertificateCreateWithData", referenced from:
      _crypto/x509/internal/macos.x509_SecCertificateCreateWithData_trampoline.abi0 in donutloadable.a(go.o)
  "_SecPolicyCreateSSL", referenced from:
      _crypto/x509/internal/macos.x509_SecPolicyCreateSSL_trampoline.abi0 in donutloadable.a(go.o)
  "_SecTrustCreateWithCertificates", referenced from:
      _crypto/x509/internal/macos.x509_SecTrustCreateWithCertificates_trampoline.abi0 in donutloadable.a(go.o)
  "_SecTrustEvaluateWithError", referenced from:
      _crypto/x509/internal/macos.x509_SecTrustEvaluateWithError_trampoline.abi0 in donutloadable.a(go.o)
  "_SecTrustGetCertificateAtIndex", referenced from:
      _crypto/x509/internal/macos.x509_SecTrustGetCertificateAtIndex_trampoline.abi0 in donutloadable.a(go.o)
  "_SecTrustGetCertificateCount", referenced from:
      _crypto/x509/internal/macos.x509_SecTrustGetCertificateCount_trampoline.abi0 in donutloadable.a(go.o)
  "_SecTrustSetVerifyDate", referenced from:
      _crypto/x509/internal/macos.x509_SecTrustSetVerifyDate_trampoline.abi0 in donutloadable.a(go.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

After success build I get error to load library:

/opt/homebrew/opt/sqlite/bin/sqlite3 Chinook_Sqlite.sqlite -bail \ 
  -cmd '.load donutdb.so'
sqlite3vfs register donutdb
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x2 addr=0x468 pc=0x105a392ec]

runtime stack:
runtime.throw({0x105a53213?, 0x14000305d40?})
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/panic.go:1047 +0x40 fp=0x16b58da90 sp=0x16b58da60 pc=0x1056e5690
runtime.sigpanic()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/signal_unix.go:819 +0x1e4 fp=0x16b58dac0 sp=0x16b58da90 pc=0x1056fb8e4

goroutine 17 [syscall, locked to thread]:
runtime.cgocall(0x105a3926c, 0x140000cfbb8)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/cgocall.go:158 +0x54 fp=0x140000cfb80 sp=0x140000cfb40 pc=0x1056b4a54
github.com/psanford/sqlite3vfs._Cfunc_s3vfsNew(0x600002de00e0, 0x400)
	_cgo_gotypes.go:209 +0x38 fp=0x140000cfbb0 sp=0x140000cfb80 pc=0x1059fb998
github.com/psanford/sqlite3vfs.newVFS({0x105a3b21a, 0x7}, {0x105c3ab40?, 0x14000099ad0}, 0x400)
	/Users/leo/go/pkg/mod/github.com/psanford/sqlite3vfs@v0.0.0-20210815122246-1982a81ea618/sqlite3vfscgo.go:28 +0xa8 fp=0x140000cfc10 sp=0x140000cfbb0 pc=0x1059fbb08
github.com/psanford/sqlite3vfs.RegisterVFS({0x105a3b21a, 0x7}, {0x105c39a78?, 0x14000305da0}, {0x0, 0x0, 0x0?})
	/Users/leo/go/pkg/mod/github.com/psanford/sqlite3vfs@v0.0.0-20210815122246-1982a81ea618/sqlite3vfs.go:28 +0xe0 fp=0x140000cfc70 sp=0x140000cfc10 pc=0x1059fb600
main.DonutDBRegister()
	/Users/leo/Downloads/badgervfs/donutdb/donutdb-loadable/donut_loadable.go:44 +0x17c fp=0x140000cfdf0 sp=0x140000cfc70 pc=0x105a383ac
_cgoexp_be60145b70ad_DonutDBRegister(0x105c33cd8?)
	_cgo_gotypes.go:39 +0x1c fp=0x140000cfe00 sp=0x140000cfdf0 pc=0x105a3848c
runtime.cgocallbackg1(0x105a38470, 0x0?, 0x0)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/cgocall.go:316 +0x244 fp=0x140000cfef0 sp=0x140000cfe00 pc=0x1056b4e74
runtime.cgocallbackg(0x0?, 0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/cgocall.go:235 +0xd8 fp=0x140000cff80 sp=0x140000cfef0 pc=0x1056b4ba8
runtime.cgocallbackg(0x105a38470, 0x16b58dc3f, 0x0)
	<autogenerated>:1 +0x1c fp=0x140000cffb0 sp=0x140000cff80 pc=0x1057162cc
runtime.cgocallback(0x0, 0x0, 0x0)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1087 +0xa0 fp=0x140000cffe0 sp=0x140000cffb0 pc=0x105714be0
runtime.goexit()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1165 +0x4 fp=0x140000cffe0 sp=0x140000cffe0 pc=0x105714cb4

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000054fa0 sp=0x14000054f80 pc=0x1056e7fd4
runtime.goparkunlock(...)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:369
runtime.forcegchelper()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:302 +0xac fp=0x14000054fd0 sp=0x14000054fa0 pc=0x1056e7e6c
runtime.goexit()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1165 +0x4 fp=0x14000054fd0 sp=0x14000054fd0 pc=0x105714cb4
created by runtime.init.6
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:290 +0x24

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000055770 sp=0x14000055750 pc=0x1056e7fd4
runtime.goparkunlock(...)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:369
runtime.bgsweep(0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/mgcsweep.go:278 +0xa4 fp=0x140000557b0 sp=0x14000055770 pc=0x1056d52c4
runtime.gcenable.func1()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/mgc.go:178 +0x28 fp=0x140000557d0 sp=0x140000557b0 pc=0x1056c9b08
runtime.goexit()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1165 +0x4 fp=0x140000557d0 sp=0x140000557d0 pc=0x105714cb4
created by runtime.gcenable
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/mgc.go:178 +0x74

goroutine 4 [GC scavenge wait]:
runtime.gopark(0x1400007e000?, 0x105b8adf0?, 0x1?, 0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000055f50 sp=0x14000055f30 pc=0x1056e7fd4
runtime.goparkunlock(...)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:369
runtime.(*scavengerState).park(0x105e76500)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/mgcscavenge.go:389 +0x5c fp=0x14000055f80 sp=0x14000055f50 pc=0x1056d327c
runtime.bgscavenge(0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/mgcscavenge.go:617 +0x44 fp=0x14000055fb0 sp=0x14000055f80 pc=0x1056d3824
runtime.gcenable.func2()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/mgc.go:179 +0x28 fp=0x14000055fd0 sp=0x14000055fb0 pc=0x1056c9aa8
runtime.goexit()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1165 +0x4 fp=0x14000055fd0 sp=0x14000055fd0 pc=0x105714cb4
created by runtime.gcenable
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/mgc.go:179 +0xb8

goroutine 19 [finalizer wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000050580 sp=0x14000050560 pc=0x1056e7fd4
runtime.goparkunlock(...)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:369
runtime.runfinq()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/mfinal.go:180 +0x120 fp=0x140000507d0 sp=0x14000050580 pc=0x1056c8d30
runtime.goexit()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1165 +0x4 fp=0x140000507d0 sp=0x140000507d0 pc=0x105714cb4
created by runtime.createfing
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/mfinal.go:157 +0x84

goroutine 20 [chan receive]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000050dc0 sp=0x14000050da0 pc=0x1056e7fd4
runtime.chanrecv(0x1400008e0c0, 0x14000050eb7, 0x1)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:583 +0x454 fp=0x14000050e50 sp=0x14000050dc0 pc=0x1056b77e4
runtime.chanrecv2(0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:447 +0x14 fp=0x14000050e80 sp=0x14000050e50 pc=0x1056b7374
github.com/klauspost/compress/zstd.(*blockDec).startDecoder(0x140003109c0)
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:212 +0x74 fp=0x14000050fb0 sp=0x14000050e80 pc=0x105a0ef24
github.com/klauspost/compress/zstd.newBlockDec.func1()
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x28 fp=0x14000050fd0 sp=0x14000050fb0 pc=0x105a0eae8
runtime.goexit()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1165 +0x4 fp=0x14000050fd0 sp=0x14000050fd0 pc=0x105714cb4
created by github.com/klauspost/compress/zstd.newBlockDec
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x134

goroutine 21 [chan receive]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xe4 fp=0x140000515c0 sp=0x140000515a0 pc=0x1056e7fd4
runtime.chanrecv(0x1400008e120, 0x140000516b7, 0x1)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:583 +0x454 fp=0x14000051650 sp=0x140000515c0 pc=0x1056b77e4
runtime.chanrecv2(0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:447 +0x14 fp=0x14000051680 sp=0x14000051650 pc=0x1056b7374
github.com/klauspost/compress/zstd.(*blockDec).startDecoder(0x14000310a90)
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:212 +0x74 fp=0x140000517b0 sp=0x14000051680 pc=0x105a0ef24
github.com/klauspost/compress/zstd.newBlockDec.func1()
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x28 fp=0x140000517d0 sp=0x140000517b0 pc=0x105a0eae8
runtime.goexit()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1165 +0x4 fp=0x140000517d0 sp=0x140000517d0 pc=0x105714cb4
created by github.com/klauspost/compress/zstd.newBlockDec
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x134

goroutine 22 [chan receive]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000284dc0 sp=0x14000284da0 pc=0x1056e7fd4
runtime.chanrecv(0x1400008e180, 0x14000284eb7, 0x1)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:583 +0x454 fp=0x14000284e50 sp=0x14000284dc0 pc=0x1056b77e4
runtime.chanrecv2(0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:447 +0x14 fp=0x14000284e80 sp=0x14000284e50 pc=0x1056b7374
github.com/klauspost/compress/zstd.(*blockDec).startDecoder(0x14000310b60)
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:212 +0x74 fp=0x14000284fb0 sp=0x14000284e80 pc=0x105a0ef24
github.com/klauspost/compress/zstd.newBlockDec.func1()
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x28 fp=0x14000284fd0 sp=0x14000284fb0 pc=0x105a0eae8
runtime.goexit()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1165 +0x4 fp=0x14000284fd0 sp=0x14000284fd0 pc=0x105714cb4
created by github.com/klauspost/compress/zstd.newBlockDec
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x134

goroutine 23 [chan receive]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xe4 fp=0x140000525c0 sp=0x140000525a0 pc=0x1056e7fd4
runtime.chanrecv(0x1400008e1e0, 0x140000526b7, 0x1)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:583 +0x454 fp=0x14000052650 sp=0x140000525c0 pc=0x1056b77e4
runtime.chanrecv2(0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:447 +0x14 fp=0x14000052680 sp=0x14000052650 pc=0x1056b7374
github.com/klauspost/compress/zstd.(*blockDec).startDecoder(0x14000310c30)
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:212 +0x74 fp=0x140000527b0 sp=0x14000052680 pc=0x105a0ef24
github.com/klauspost/compress/zstd.newBlockDec.func1()
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x28 fp=0x140000527d0 sp=0x140000527b0 pc=0x105a0eae8
runtime.goexit()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1165 +0x4 fp=0x140000527d0 sp=0x140000527d0 pc=0x105714cb4
created by github.com/klauspost/compress/zstd.newBlockDec
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x134

goroutine 24 [chan receive]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000052dc0 sp=0x14000052da0 pc=0x1056e7fd4
runtime.chanrecv(0x1400008e240, 0x14000052eb7, 0x1)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:583 +0x454 fp=0x14000052e50 sp=0x14000052dc0 pc=0x1056b77e4
runtime.chanrecv2(0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:447 +0x14 fp=0x14000052e80 sp=0x14000052e50 pc=0x1056b7374
github.com/klauspost/compress/zstd.(*blockDec).startDecoder(0x14000310d00)
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:212 +0x74 fp=0x14000052fb0 sp=0x14000052e80 pc=0x105a0ef24
github.com/klauspost/compress/zstd.newBlockDec.func1()
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x28 fp=0x14000052fd0 sp=0x14000052fb0 pc=0x105a0eae8
runtime.goexit()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1165 +0x4 fp=0x14000052fd0 sp=0x14000052fd0 pc=0x105714cb4
created by github.com/klauspost/compress/zstd.newBlockDec
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x134

goroutine 25 [chan receive]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xe4 fp=0x140000535c0 sp=0x140000535a0 pc=0x1056e7fd4
runtime.chanrecv(0x1400008e2a0, 0x140000536b7, 0x1)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:583 +0x454 fp=0x14000053650 sp=0x140000535c0 pc=0x1056b77e4
runtime.chanrecv2(0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:447 +0x14 fp=0x14000053680 sp=0x14000053650 pc=0x1056b7374
github.com/klauspost/compress/zstd.(*blockDec).startDecoder(0x14000310dd0)
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:212 +0x74 fp=0x140000537b0 sp=0x14000053680 pc=0x105a0ef24
github.com/klauspost/compress/zstd.newBlockDec.func1()
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x28 fp=0x140000537d0 sp=0x140000537b0 pc=0x105a0eae8
runtime.goexit()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1165 +0x4 fp=0x140000537d0 sp=0x140000537d0 pc=0x105714cb4
created by github.com/klauspost/compress/zstd.newBlockDec
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x134

goroutine 26 [chan receive]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000053dc0 sp=0x14000053da0 pc=0x1056e7fd4
runtime.chanrecv(0x1400008e300, 0x14000053eb7, 0x1)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:583 +0x454 fp=0x14000053e50 sp=0x14000053dc0 pc=0x1056b77e4
runtime.chanrecv2(0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:447 +0x14 fp=0x14000053e80 sp=0x14000053e50 pc=0x1056b7374
github.com/klauspost/compress/zstd.(*blockDec).startDecoder(0x14000310ea0)
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:212 +0x74 fp=0x14000053fb0 sp=0x14000053e80 pc=0x105a0ef24
github.com/klauspost/compress/zstd.newBlockDec.func1()
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x28 fp=0x14000053fd0 sp=0x14000053fb0 pc=0x105a0eae8
runtime.goexit()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1165 +0x4 fp=0x14000053fd0 sp=0x14000053fd0 pc=0x105714cb4
created by github.com/klauspost/compress/zstd.newBlockDec
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x134

goroutine 27 [chan receive]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xe4 fp=0x140003325c0 sp=0x140003325a0 pc=0x1056e7fd4
runtime.chanrecv(0x1400008e360, 0x140003326b7, 0x1)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:583 +0x454 fp=0x14000332650 sp=0x140003325c0 pc=0x1056b77e4
runtime.chanrecv2(0x0?, 0x0?)
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/chan.go:447 +0x14 fp=0x14000332680 sp=0x14000332650 pc=0x1056b7374
github.com/klauspost/compress/zstd.(*blockDec).startDecoder(0x14000310f70)
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:212 +0x74 fp=0x140003327b0 sp=0x14000332680 pc=0x105a0ef24
github.com/klauspost/compress/zstd.newBlockDec.func1()
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x28 fp=0x140003327d0 sp=0x140003327b0 pc=0x105a0eae8
runtime.goexit()
	/opt/homebrew/Cellar/go/1.19/libexec/src/runtime/asm_arm64.s:1165 +0x4 fp=0x140003327d0 sp=0x140003327d0 pc=0x105714cb4
created by github.com/klauspost/compress/zstd.newBlockDec
	/Users/leo/go/pkg/mod/github.com/klauspost/compress@v1.13.4/zstd/blockdec.go:118 +0x134
[1]    83608 abort      /opt/homebrew/opt/sqlite/bin/sqlite3 Chinook_Sqlite.sqlite -bail -cmd

First I start thinking issue with my code, but I did try to use https://github.com/psanford/donutdb and get same issue. I don't know C, but ready to provide any info if needed.

✔  go version 
go version go1.19 darwin/arm64

✔  gcc --version 
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

✔  /opt/homebrew/opt/sqlite/bin/sqlite3 --version 
3.39.2 2022-07-21 15:24:47 698edb77537b67c41adc68f9b892db56bcf9a55e00371a61420f3ddd668e6603

Again, thanks for your work!

Ok, additional info - I did build on Intel based mac os - same issue:

/usr/local/opt/sqlite/bin/sqlite3 Chinook_Sqlite.sqlite -bail -cmd '.load badgervfs.so'
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x468 pc=0x103546d34]

runtime stack:
runtime.throw({0x10355e281?, 0x7ff803e1bb75?})
	/usr/local/Cellar/go/1.19/libexec/src/runtime/panic.go:1047 +0x5d fp=0x7ff7bda33e20 sp=0x7ff7bda33df0 pc=0x1031b675d
runtime.sigpanic()
	/usr/local/Cellar/go/1.19/libexec/src/runtime/signal_unix.go:819 +0x369 fp=0x7ff7bda33e70 sp=0x7ff7bda33e20 pc=0x1031cc1c9

goroutine 17 [syscall, locked to thread]:
runtime.cgocall(0x103546cc0, 0xc00005ad18)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/cgocall.go:158 +0x5c fp=0xc00005acf0 sp=0xc00005acb8 pc=0x10318467c
github.com/psanford/sqlite3vfs._Cfunc_s3vfsNew(0x60000211c040, 0x400)
	_cgo_gotypes.go:209 +0x4c fp=0xc00005ad18 sp=0xc00005acf0 pc=0x10354242c
github.com/psanford/sqlite3vfs.newVFS({0x10354bb22, 0x9}, {0x1036bb610?, 0xc00027e3f0}, 0x400)
	/Users/leo/go/pkg/mod/github.com/psanford/sqlite3vfs@v0.0.0-20220823065410-bd28ac7ee3c2/sqlite3vfscgo.go:28 +0xa6 fp=0xc00005ad70 sp=0xc00005ad18 pc=0x1035425e6
github.com/psanford/sqlite3vfs.RegisterVFS({0x10354bb22, 0x9}, {0x1036b9d60?, 0x103983228}, {0x0, 0x0, 0xc00005ae20?})
	/Users/leo/go/pkg/mod/github.com/psanford/sqlite3vfs@v0.0.0-20220823065410-bd28ac7ee3c2/sqlite3vfs.go:28 +0xee fp=0xc00005adc8 sp=0xc00005ad70 pc=0x103541f8e
main.BadgerVFSRegister()
	/Users/leo/Downloads/sqlite_test/badgervfs/badgervfs_ext.go:32 +0x3b fp=0xc00005ae20 sp=0xc00005adc8 pc=0x1035455db
_cgoexp_08eb5ab81f79_BadgerVFSRegister(0x1036b5ac0?)
	_cgo_gotypes.go:39 +0x17 fp=0xc00005ae30 sp=0xc00005ae20 pc=0x103545f57
runtime.cgocallbackg1(0x103545f40, 0x0?, 0x0)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/cgocall.go:316 +0x2b4 fp=0xc00005af00 sp=0xc00005ae30 pc=0x103184b94
runtime.cgocallbackg(0x0?, 0x0?, 0x0?)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/cgocall.go:235 +0x109 fp=0xc00005af90 sp=0xc00005af00 pc=0x103184829
runtime.cgocallbackg(0x103545f40, 0x7ff7bda33f97, 0x0)
	<autogenerated>:1 +0x2f fp=0xc00005afb8 sp=0xc00005af90 pc=0x1031e924f
runtime.cgocallback(0x0, 0x0, 0x0)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/asm_amd64.s:994 +0xb4 fp=0xc00005afe0 sp=0xc00005afb8 pc=0x1031e6db4
runtime.goexit()
	/usr/local/Cellar/go/1.19/libexec/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00005afe8 sp=0xc00005afe0 pc=0x1031e6fc1

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xd6 fp=0xc000048fb0 sp=0xc000048f90 pc=0x1031b9336
runtime.goparkunlock(...)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/proc.go:369
runtime.forcegchelper()
	/usr/local/Cellar/go/1.19/libexec/src/runtime/proc.go:302 +0xad fp=0xc000048fe0 sp=0xc000048fb0 pc=0x1031b91cd
runtime.goexit()
	/usr/local/Cellar/go/1.19/libexec/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000048fe8 sp=0xc000048fe0 pc=0x1031e6fc1
created by runtime.init.6
	/usr/local/Cellar/go/1.19/libexec/src/runtime/proc.go:290 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xd6 fp=0xc000049790 sp=0xc000049770 pc=0x1031b9336
runtime.goparkunlock(...)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/proc.go:369
runtime.bgsweep(0x0?)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/mgcsweep.go:278 +0x8e fp=0xc0000497c8 sp=0xc000049790 pc=0x1031a548e
runtime.gcenable.func1()
	/usr/local/Cellar/go/1.19/libexec/src/runtime/mgc.go:178 +0x26 fp=0xc0000497e0 sp=0xc0000497c8 pc=0x10319a146
runtime.goexit()
	/usr/local/Cellar/go/1.19/libexec/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0000497e8 sp=0xc0000497e0 pc=0x1031e6fc1
created by runtime.gcenable
	/usr/local/Cellar/go/1.19/libexec/src/runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc000072000?, 0x1035f9a00?, 0x1?, 0x0?, 0x0?)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xd6 fp=0xc000049f70 sp=0xc000049f50 pc=0x1031b9336
runtime.goparkunlock(...)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/proc.go:369
runtime.(*scavengerState).park(0x1039527a0)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/mgcscavenge.go:389 +0x53 fp=0xc000049fa0 sp=0xc000049f70 pc=0x1031a3533
runtime.bgscavenge(0x0?)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/mgcscavenge.go:617 +0x45 fp=0xc000049fc8 sp=0xc000049fa0 pc=0x1031a3b05
runtime.gcenable.func2()
	/usr/local/Cellar/go/1.19/libexec/src/runtime/mgc.go:179 +0x26 fp=0xc000049fe0 sp=0xc000049fc8 pc=0x10319a0e6
runtime.goexit()
	/usr/local/Cellar/go/1.19/libexec/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000049fe8 sp=0xc000049fe0 pc=0x1031e6fc1
created by runtime.gcenable
	/usr/local/Cellar/go/1.19/libexec/src/runtime/mgc.go:179 +0xaa

goroutine 5 [finalizer wait]:
runtime.gopark(0x103952c60?, 0xc000007860?, 0x0?, 0x0?, 0xc000048770?)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xd6 fp=0xc000048628 sp=0xc000048608 pc=0x1031b9336
runtime.goparkunlock(...)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/proc.go:369
runtime.runfinq()
	/usr/local/Cellar/go/1.19/libexec/src/runtime/mfinal.go:180 +0x10f fp=0xc0000487e0 sp=0xc000048628 pc=0x10319924f
runtime.goexit()
	/usr/local/Cellar/go/1.19/libexec/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0000487e8 sp=0xc0000487e0 pc=0x1031e6fc1
created by runtime.createfing
	/usr/local/Cellar/go/1.19/libexec/src/runtime/mfinal.go:157 +0x45

goroutine 6 [chan receive]:
runtime.gopark(0xc00004a6d8?, 0x1031bf15b?, 0x20?, 0xa7?, 0x1031d5b65?)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/proc.go:363 +0xd6 fp=0xc00004a6c8 sp=0xc00004a6a8 pc=0x1031b9336
runtime.chanrecv(0xc00008e000, 0xc00004a7a0, 0x1)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/chan.go:583 +0x49b fp=0xc00004a758 sp=0xc00004a6c8 pc=0x10318767b
runtime.chanrecv2(0x6fc23ac00?, 0x0?)
	/usr/local/Cellar/go/1.19/libexec/src/runtime/chan.go:447 +0x18 fp=0xc00004a780 sp=0xc00004a758 pc=0x1031871b8
github.com/golang/glog.(*loggingT).flushDaemon(0x0?)
	/Users/leo/go/pkg/mod/github.com/golang/glog@v0.0.0-20160126235308-23def4e6c14b/glog.go:882 +0x6a fp=0xc00004a7c8 sp=0xc00004a780 pc=0x10345c76a
github.com/golang/glog.init.0.func1()
	/Users/leo/go/pkg/mod/github.com/golang/glog@v0.0.0-20160126235308-23def4e6c14b/glog.go:410 +0x26 fp=0xc00004a7e0 sp=0xc00004a7c8 pc=0x10345a806
runtime.goexit()
	/usr/local/Cellar/go/1.19/libexec/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00004a7e8 sp=0xc00004a7e0 pc=0x1031e6fc1
created by github.com/golang/glog.init.0
	/Users/leo/go/pkg/mod/github.com/golang/glog@v0.0.0-20160126235308-23def4e6c14b/glog.go:410 +0x1bf

Is it just the loadable module that is failing on macOS? For example, can you try the example cli tool sqlitehttpcli in https://github.com/psanford/sqlite3vfshttp against one of the demo queries in the readme, e.g.:

./sqlitehttpcli -url 'https://www.sanford.io/demo.db' -query "select * from csv limit 10"

I would expect the above to work on macOS. I've not tested the loadable module on macOS so its not too that some things need to be adjusted to get that working. I'll take a look when I have some time.

Hello.

yep, it works (just have some "protocol error: received DATA after END_STREAM", but I think it is fine):

./sqlitehttpcli -url 'https://www.sanford.io/demo.db' -query "select * from csv limit 10"
2022/08/27 18:43:30 protocol error: received DATA after END_STREAM
2022/08/27 18:43:30 protocol error: received DATA after END_STREAM
2022/08/27 18:43:30 protocol error: received DATA after END_STREAM
2022/08/27 18:43:30 protocol error: received DATA after END_STREAM
2022/08/27 18:43:30 protocol error: received DATA after END_STREAM
row: [BOPQ.S06AC000000000A 1971.06 426  F Dollars 6 Balance of Payments - BOP BPM6 Quarterly, Balance of payments major components Actual]
row: [BOPQ.S06AC000000000A 1971.09 435  F Dollars 6 Balance of Payments - BOP BPM6 Quarterly, Balance of payments major components Actual]
row: [BOPQ.S06AC000000000A 1971.12 360  F Dollars 6 Balance of Payments - BOP BPM6 Quarterly, Balance of payments major components Actual]
row: [BOPQ.S06AC000000000A 1972.03 417  F Dollars 6 Balance of Payments - BOP BPM6 Quarterly, Balance of payments major components Actual]
row: [BOPQ.S06AC000000000A 1972.06 528  F Dollars 6 Balance of Payments - BOP BPM6 Quarterly, Balance of payments major components Actual]
row: [BOPQ.S06AC000000000A 1972.09 471  F Dollars 6 Balance of Payments - BOP BPM6 Quarterly, Balance of payments major components Actual]
row: [BOPQ.S06AC000000000A 1972.12 437  F Dollars 6 Balance of Payments - BOP BPM6 Quarterly, Balance of payments major components Actual]
row: [BOPQ.S06AC000000000A 1973.03 607  F Dollars 6 Balance of Payments - BOP BPM6 Quarterly, Balance of payments major components Actual]
row: [BOPQ.S06AC000000000A 1973.06 666  F Dollars 6 Balance of Payments - BOP BPM6 Quarterly, Balance of payments major components Actual]
row: [BOPQ.S06AC000000000A 1973.09 578  F Dollars 6 Balance of Payments - BOP BPM6 Quarterly, Balance of payments major components Actual]

Looks like you are right - loadable module works fine on linux system (just tested on ubuntu), but fail in darwin system.

I'm having the same issue. I did create psanford/sqlite3vfshttp#7, something similar could be done here for the first part of this issue. I think the crash may be due to handling loading differently in sqlite3 .load, and how sqlitehttpcli does it, by asking mattn/go-sqlite3 to do the load? I expect the difference is something tiny missing for handling things purely on the C-side in MacOS.

The crash in sqlite3vfshttp is because it is using the system MacOS sqlite3ext.h, which for some bizarre reason defines SQLITE_OMIT_LOAD_EXTENSION, which makes initializing the API a no-op. I can't work out how to make external packages use the the sqlite3 headers inside this repo, which is the logical thing to do.

@psanford I would love your input on this, perhaps there's a way to ensure the sqlite headers from this repo are included from extensions built elsewhere, like sqlite3vfshttp.