Strange CFFI callback error with SBCL - lisp

I have this Common Lisp code which is a CFFI binding to PortAudio : https://github.com/thodg/cffi-portaudio
First time I build with ASDF it gives no warning, but if I try to reload the system it tells me about these :
STYLE-WARNING: Undefined alien: "Pa_GetErrorText"
STYLE-WARNING: Undefined alien: "Pa_Initialize"
STYLE-WARNING: Undefined alien: "Pa_Terminate"
STYLE-WARNING: Undefined alien: "Pa_OpenStream"
STYLE-WARNING: Undefined alien: "Pa_OpenDefaultStream"
STYLE-WARNING: Undefined alien: "Pa_CloseStream"
STYLE-WARNING: Undefined alien: "Pa_StartStream"
STYLE-WARNING: Undefined alien: "Pa_StopStream"
STYLE-WARNING: Undefined alien: "Pa_AbortStream"
STYLE-WARNING: Undefined alien: "Pa_IsStreamStopped"
STYLE-WARNING: Undefined alien: "Pa_IsStreamActive"
And then -- wether I load the code once or twice, it makes no difference -- if I run the TEST function it crashes SBCL with this strange message :
"callback" CORRUPTION WARNING in SBCL pid 3501(tid 0x7fffe0ac9700):
Received signal 8 in non-lisp thread 140736962795264, resignalling to a lisp thread.
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
Process inferior-lisp floating point exception
There are no floats in my callback, so the error seems very strange to me.
Everything before START-STREAM seems to run properly. But then START-STREAM jumps on the callback and it crashes.
What am I doing wrong ?

Related

Getting "undefined symbol: Float8GetDatum" when creating function in PostgreSQL

I am using postgresql 11.5 in redhat linux 7.3.
In the sql script, the function is created as following:
create or replace function alpine_miner_float_array_sum_accum(state float[], ind float[])
returns float[]
AS 'alpine_miner', 'alpine_miner_float_array_sum_accum'
language C immutable;
But it gives the following error:
ERROR: could not load library "/usr/pgsql-11/lib/alpine_miner.so": /usr/pgsql-11/lib/alpine_miner.so: undefined symbol: Float8GetDatum
SQL state: XX000
I found that /usr/pgsql-11/lib/alpine_miner.so does exist and the output of ld command:
linux-vdso.so.1 => (0x00007ffda65d6000)
libc.so.6 => /lib64/libc.so.6 (0x00007eff25a67000)
/lib64/ld-linux-x86-64.so.2 (0x00007eff26051000)
ldd command:
ld: warning: cannot find entry symbol _start; not setting start address
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `construct_md_array'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `get_call_result_type'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `ArrayGetNItems'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `logf'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `deconstruct_array'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `CurrentMemoryContext'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `acosf'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `GetAttributeByName'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `elog_finish'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `errstart'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `pg_detoast_datum'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `exp'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `sqrtf'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `MemoryContextAllocZero'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `elog_start'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `errmsg'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `BlessTupleDesc'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `get_typlenbyvalalign'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `Float8GetDatum'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `log'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `pow'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `errdetail'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `DatumGetFloat8'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `errfinish'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `sqrt'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `heap_form_tuple'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `format_procedure'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `construct_array'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `MemoryContextAlloc'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `pfree'
/usr/pgsql-11/lib/alpine_miner.so: undefined reference to `errcode'
Any idea with that? Thanks in advance.
When you built alpine_miner.so, you built it against a PostgreSQL installation that was configured differently from the one where you are trying to use it.
In the case of the title problem, alpine_miner.so was built with USE_FLOAT8_BYVAL undefined, but your PostgreSQL has it defined:
#ifdef USE_FLOAT8_BYVAL
static inline Datum
Float8GetDatum(float8 X)
{
union
{
float8 value;
int64 retval;
} myunion;
myunion.value = X;
return Int64GetDatum(myunion.retval);
}
#else
extern Datum Float8GetDatum(float8 X);
#endif
But the list of undefined linker references also suggests that you are trying to load the shared object into a PostgreSQL that is either ancient or modified:
For example, BlessTupleDesc has been in the server since commit 375369acd1c in April 2004.
To get further help, you'll have to disclose the exact make and version of your PostgreSQL and the exact build process for alpine_miner.so.

Error while running make command for srilm

While executing make command, I recieve the following error:
/home/cse/phd/16071009/NLP//lib/i686-m64/libmisc.a(File.o): In function File::~File()':
/home/cse/phd/16071009/NLP/misc/src/File.cc:127: undefined reference tolibiconv_close'
/home/cse/phd/16071009/NLP//lib/i686-m64/libmisc.a(File.o): In function File::reopen(char const*, char const*)':
/home/cse/phd/16071009/NLP/misc/src/File.cc:167: undefined reference tolibiconv_close'
/home/cse/phd/16071009/NLP//lib/i686-m64/libmisc.a(File.o): In function File::reopen(char const*)':
/home/cse/phd/16071009/NLP/misc/src/File.cc:217: undefined reference tolibiconv_close'
/home/cse/phd/16071009/NLP//lib/i686-m64/libmisc.a(File.o): In function File::reopen(char const*, unsigned long, int)':
/home/cse/phd/16071009/NLP/misc/src/File.cc:249: undefined reference tolibiconv_close'
/home/cse/phd/16071009/NLP//lib/i686-m64/libmisc.a(File.o): In function File::reopen(std::string&, int)':
/home/cse/phd/16071009/NLP/misc/src/File.cc:273: undefined reference tolibiconv_close'
/home/cse/phd/16071009/NLP//lib/i686-m64/libmisc.a(File.o): In function File::fgetsUTF8(char*, int)':
/home/cse/phd/16071009/NLP/misc/src/File.cc:387: undefined reference tolibiconv'
/home/cse/phd/16071009/NLP/misc/src/File.cc:345: undefined reference to libiconv_open'
/home/cse/phd/16071009/NLP/misc/src/File.cc:349: undefined reference tolibiconv_open'
collect2: error: ld returned 1 exit status
test -f ../bin/i686-m64/ngram
make[2]: * [../bin/i686-m64/ngram] Error 1
make[2]: Leaving directory /home/cse/phd/16071009/NLP/lm/src'
make[1]: *** [release-programs] Error 1
make[1]: Leaving directory/home/cse/phd/16071009/NLP'
make: * [World] Error 2
[16071009#compute-01 NLP]$
The -liconv appears nowhere in the link command, so that's why you're
getting the undefined references. Try putting:
SYS_LIBRARIES = -L<path-to-libiconv_install> -liconv
For example, if you install srilm on Ubuntu x64, edit this file: common/Makefile.site.i686-m64. Make sure the -L option points to the directory that has the libiconv.so or libiconv.a file.
For me, libiconv install srilm on Ubuntu 18.04 x64 using make are locate on /usr/local/lib. So I add following line to common/Makefile.site.i686-m64:
SYS_LIBRARIES = -L/usr/local/lib -liconv
Solution from: http://mailman.speech.sri.com/pipermail/srilm-user/2014q3/001694.html

Building a statically linked executable with Swift on Ubuntu

I'm trying to build an statically linked executable from a swift source on Ubuntu.
Calling
swift build -Xswiftc -static-stdlib
as suggested in Compile Swift script with static Swift core library
returns this error:
/usr/bin/ld.gold: error: cannot find -lFoundation
Some educated guesses:
Researching this hasn't led me very far, I know it means the library can't be found. Maybe it isn't in the compiler's path ?
Full error message:
user#user-VirtualBox:/path/to/project$ swift build -Xswiftc -static-stdlib
Compile Swift Module 'projectName' (4 sources)
Linking ./.build/debug/projectName
/usr/bin/ld.gold: error: cannot find -lFoundation
/usr/bin/ld.gold: error: cannot find -lFoundation
/usr/bin/ld.gold: error: cannot find -lFoundation
/usr/bin/ld.gold: error: cannot find -lFoundation
/path/to/project/Sources/SomeClass_1.swift:67: error: undefined reference to '_TMaC10Foundation17JSONSerialization'
/path/to/project/Sources/SomeClass_1.swift:67: error: undefined reference to '_TFVC10Foundation17JSONSerialization14WritingOptionsau13prettyPrintedS1_'
/path/to/project/Sources/SomeClass_1.swift:68: error: undefined reference to '_TMaC10Foundation8NSString'
/path/to/project/Sources/SomeClass_1.swift:68: error: undefined reference to '_TFVE10FoundationSS8Encodingau4utf8S0_'
/path/to/project/Sources/SomeClass_1.swift:68: error: undefined reference to '_TFC10Foundation8NSStringCfT4dataVS_4Data8encodingSu_GSqS0__'
/path/to/project/Sources/SomeClass_1.swift:69: error: undefined reference to '_TWPC10Foundation8NSObjects9EquatableS_'
/path/to/project/Sources/SomeClass_1.swift:72: error: undefined reference to '_TFC10Foundation8NSStringCfT13stringLiteralVs12StaticString_S0_'
/path/to/project/Sources/SomeClass_1.swift:76: error: undefined reference to '_TMaC10Foundation8NSString'
/path/to/project/Sources/SomeClass_1.swift:76: error: undefined reference to '_TFC10Foundation8NSStringCfT13stringLiteralVs12StaticString_S0_'
/path/to/project/Sources/SomeClass_2.swift:73: error: undefined reference to '_TMaC10Foundation17JSONSerialization'
/path/to/project/Sources/SomeClass_2.swift:73: error: undefined reference to '_TFVC10Foundation17JSONSerialization14WritingOptionsau13prettyPrintedS1_'
/path/to/project/Sources/SomeClass_2.swift:74: error: undefined reference to '_TMaC10Foundation8NSString'
/path/to/project/Sources/SomeClass_2.swift:74: error: undefined reference to '_TFVE10FoundationSS8Encodingau4utf8S0_'
/path/to/project/Sources/SomeClass_2.swift:74: error: undefined reference to '_TFC10Foundation8NSStringCfT4dataVS_4Data8encodingSu_GSqS0__'
/path/to/project/Sources/SomeClass_2.swift:75: error: undefined reference to '_TWPC10Foundation8NSObjects9EquatableS_'
/path/to/project/Sources/SomeClass_2.swift:78: error: undefined reference to '_TFC10Foundation8NSStringCfT13stringLiteralVs12StaticString_S0_'
/path/to/project/Sources/SomeClass_2.swift:82: error: undefined reference to '_TMaC10Foundation8NSString'
/path/to/project/Sources/SomeClass_2.swift:82: error: undefined reference to '_TFC10Foundation8NSStringCfT13stringLiteralVs12StaticString_S0_'
/path/to/project/Sources/SomeClass_3.swift:106: error: undefined reference to '_TMaC10Foundation17JSONSerialization'
/path/to/project/Sources/SomeClass_3.swift:106: error: undefined reference to '_TFVC10Foundation17JSONSerialization14WritingOptionsau13prettyPrintedS1_'
/path/to/project/Sources/SomeClass_3.swift:107: error: undefined reference to '_TFVE10FoundationSS8Encodingau4utf8S0_'
/path/to/project/Sources/SomeClass_3.swift:107: error: undefined reference to '_TFC10Foundation8NSStringCfT4dataVS_4Data8encodingSu_GSqS0__'
/path/to/project/Sources/SomeClass_3.swift:108: error: undefined reference to '_TWPC10Foundation8NSObjects9EquatableS_'
/path/to/project/Sources/main.swift:24: error: undefined reference to '_TMaC10Foundation12NSDictionary'
/path/to/project/Sources/main.swift:24: error: undefined reference to '_TFC10Foundation12NSDictionaryCft17dictionaryLiteralGSaTP_P____S0_'
/path/to/project/Sources/main.swift:51: error: undefined reference to '_TMaC10Foundation12NSDictionary'
/path/to/project/Sources/main.swift:51: error: undefined reference to '_TFC10Foundation12NSDictionaryCft17dictionaryLiteralGSaTP_P____S0_'
/path/to/project/Sources/main.swift:99: error: undefined reference to '_TMaC10Foundation12NSDictionary'
/path/to/project/Sources/main.swift:99: error: undefined reference to '_TFC10Foundation12NSDictionaryCft17dictionaryLiteralGSaTP_P____S0_'
/path/to/project/Sources/main.swift:112: error: undefined reference to '_TMaC10Foundation12NSDictionary'
/path/to/project/Sources/main.swift:112: error: undefined reference to '_TFC10Foundation12NSDictionaryCft17dictionaryLiteralGSaTP_P____S0_'
/path/to/project/Sources/main.swift:167: error: undefined reference to '_TMaC10Foundation17JSONSerialization'
/path/to/project/Sources/main.swift:167: error: undefined reference to '_TFVC10Foundation17JSONSerialization14WritingOptionsau13prettyPrintedS1_'
/path/to/project/Sources/main.swift:168: error: undefined reference to '_TFVE10FoundationSS8Encodingau4utf8S0_'
/path/to/project/Sources/main.swift:168: error: undefined reference to '_TFC10Foundation8NSStringCfT4dataVS_4Data8encodingSu_GSqS0__'
/path/to/project/Sources/main.swift:169: error: undefined reference to '_TWPC10Foundation8NSObjects9EquatableS_'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: build had 1 command failures
error: exit(1): /path/to/swift-3.0.2-RELEASE-ubuntu16.04/usr/bin/swift-build-tool -f /path/to/project/.build/debug.yaml
The problem is that Foundation is not available as static library. There is an open bug for this:
https://bugs.swift.org/browse/SR-2205
You might be able to work around this problem if you could build a static Foundation lib, e.g. as part of building Swift from source.

repl hangs for ~15 seconds on each error (emacs + cider + boot)

I'm facing a strange behavior whenever I invoke an error in boot-cljs-repl. The repl (actually the entire emacs) hangs for about 15 seconds and after that I see the following error message below the mode-line:
error in process filter: Lisp nesting exceedsmax-lisp-eval-depth'`
An error would e.g be calling (some-nonexisting-function) from the REPL.
Additionally I get an error message inside the REPL itself. Sorry, for posting the whole thing here - I wouldn't know right now which parts are important:
box.webgl> (some-nonexisting-function)
WARNING: Use of undeclared Var box.webgl/some-nonexisting-function at line 1 <cljs repl>
#object[TypeError TypeError: Cannot read property 'call' of undefined]
TypeError: Cannot read property 'call' of undefined
at eval (eval at <anonymous> (http://localhost:3000/main.out/weasel/repl.js:30:470), <anonymous>:1\
:124)
at eval (eval at <anonymous> (http://localhost:3000/main.out/weasel/repl.js:30:470), <anonymous>:9\
:3)
at eval (eval at <anonymous> (http://localhost:3000/main.out/weasel/repl.js:30:470), <anonymous>:1\
4:4)
at http://localhost:3000/main.out/weasel/repl.js:30:465
at http://localhost:3000/main.out/weasel/repl.js:39:4
at cljs.core.MultiFn.call.G__10839__2 (http://localhost:3000/main.out/cljs/core.js:33327:106)
at cljs.core.MultiFn.call.G__10839 [as call] (http://localhost:3000/main.out/cljs/core.js:33594:20\
)
at .<anonymous> (http://localhost:3000/main.out/weasel/repl.js:184:71)
at goog.events.EventTarget.fireListeners (http://localhost:3000/main.out/goog/events/eventtarget.j\
s:284:23)
at Function.goog.events.EventTarget.dispatchEventInternal_ (http://localhost:3000/main.out/goog/ev\
ents/eventtarget.js:381:26)
recently CIDER was changed to automatically supply it's own cider-nrepl and clj-refactor middleware when starting lein, so you can (should) remove these from your ~/.lein/profifiles.clj file if you have them. This will clear up this warning. (remember to update to the latest cider emacs package.
WARNING: CIDER's version (0.12.0-snapshot) does not match
cider-nrepl's version (not installed). Things will break!
This is a problem and hopefully fixing it clears up your other problems. If not, at least solving this is a prerequisite to debugging it properly.

fortran: using pgplot with eclipse photran

So I am really not a Fortran programmer at all, but I have some code I am working with that uses the pgplot graphics libraries in fortran. I am able to get the code running in fortran from the console using the following commands.
gfortran -o simple discrete.f -lpgplot -IX11
discrete.f is the name of the file. So this works when I run it from the console. However, I want to run the code in the eclipse photran plugin so that I can use the debugger so that I can step through the code and observe some of the variables. I tried to put the -lpgplot and -IX11 flags in Eclipse, but I am getting errors about pgbbuf and pgnumb_ functions as undefined reference (which means that the -lpgplot function is not working when called from eclipse.
Can anyone please tell me how to set the flags correctly to run this code in Photran so that I can compile it and see the pgplot figure come up?
I am adding the console output:
02:57:05 **** Clean-only build of configuration Debug for project burglar_code_martin ****
make clean
rm -rf ./burglary_model.o burglar_code_martin
02:57:05 Build Finished (took 61ms)
02:57:05 **** Build of configuration Debug for project burglar_code_martin ****
make all
Building file: ../burglary_model.f
Invoking: GNU Fortran Compiler
gfortran -funderscoring -I/usr/lib -O0 -g -Wall -c -fmessage-length=0 -lpgplot -IX11 -o "burglary_model.o" "../burglary_model.f"
Warning: Nonconforming tab character in column 1 of line 225
Warning: Nonconforming tab character in column 1 of line 228
../burglary_model.f:155.27:
call probcheck(frac,1,outc)
1
Warning: Rank mismatch in argument 'problist' at (1) (rank-1 and scalar)
../burglary_model.f:54.33:
call probcheck(robprob,1,outcome)
1
Warning: Rank mismatch in argument 'problist' at (1) (rank-1 and scalar)
../burglary_model.f:95.30:
call probcheck(placeprob,1,outcome)
1
Warning: Rank mismatch in argument 'problist' at (1) (rank-1 and scalar)
../burglary_model.f:206.36:
subroutine output(A,burgsatloc,t,l,pic,screen,A0,Bbar)
1
Warning: Unused dummy argument 'burgsatloc' at (1)
../burglary_model.f:206.44:
subroutine output(A,burgsatloc,t,l,pic,screen,A0,Bbar)
1
Warning: Unused dummy argument 'pic' at (1)
../burglary_model.f:206.51:
subroutine output(A,burgsatloc,t,l,pic,screen,A0,Bbar)
1
Warning: Unused dummy argument 'screen' at (1)
../burglary_model.f:145.32:
integer l,pic,screen,i,j,k,PGOPEN,burgsatloc(512,*),nbar,outc
1
Warning: Unused variable 'k' declared at (1)
../burglary_model.f:146.15:
real rand,red,green,blue
1
Warning: Unused variable 'rand' declared at (1)
../burglary_model.f:143.53:
subroutine initialize(burgsatloc,B,l,pic,screen,rbar,Bbar)
1
Warning: Unused dummy argument 'screen' at (1)
../burglary_model.f:4.58:
integer i,j,n,l,pic,screen,guy,burgsatloc(512,512),k,
1
Warning: Unused variable 'k' declared at (1)
Finished building: ../burglary_model.f
Building target: burglar_code_martin
Invoking: GNU Fortran Linker
gfortran -lpgplot -IX11 -o "burglar_code_martin" ./burglary_model.o
./burglary_model.o: In function `output_':
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:241: undefined reference to `pgbbuf_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:242: undefined reference to `pgnumb_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:244: undefined reference to `pgenv_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:246: undefined reference to `pglab_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:247: undefined reference to `pgimag_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:253: undefined reference to `pgebuf_'
./burglary_model.o: In function `initialize_':
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:165: undefined reference to `pgopen_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:168: undefined reference to `pgpap_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:169: undefined reference to `pgask_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:170: undefined reference to `pgscir_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:175: undefined reference to `pgscr_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:181: undefined reference to `pgscr_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:187: undefined reference to `pgscr_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:193: undefined reference to `pgscr_'
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:199: undefined reference to `pgscr_'
./burglary_model.o: In function `implicit':
/media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:109: undefined reference to `pgclos_'
collect2: ld returned 1 exit status
make: *** [burglar_code_martin] Error 1
02:57:05 Build Finished (took 209ms)