Hi,
It's great to see some support for kawa in slime.. I wanted to give it a go today but ran in a few showstoppers. With the latest kawa compiler I ran into an error which might be a compiler bug, when issuing the compile command: (compile-file "swank-kawa.scm" "swank-kawa") I get a stack trace:
java.lang.Error: popType called with empty stack swank$Mnkawa.dispatchEvents(java.net.Socket)java.lang.Object at gnu.bytecode.CodeAttr.popType(CodeAttr.java:321) at gnu.bytecode.CodeAttr.emitStore(CodeAttr.java:1204) at gnu.expr.SetExp.compile(SetExp.java:279) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileWithPosition(Expression.java:133) at gnu.expr.IfExp.compile(IfExp.java:105) at gnu.expr.IfExp.compile(IfExp.java:41) at gnu.expr.Expression.compileWithPosition(Expression.java:133) at gnu.expr.BeginExp.compile(BeginExp.java:142) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compile(Expression.java:179) at gnu.expr.SetExp.compile(SetExp.java:273) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileWithPosition(Expression.java:133) at gnu.expr.IfExp.compile(IfExp.java:105) at gnu.expr.IfExp.compile(IfExp.java:41) at gnu.expr.Expression.compileWithPosition(Expression.java:133) at gnu.expr.BeginExp.compile(BeginExp.java:142) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compile(Expression.java:179) at gnu.expr.SetExp.compile(SetExp.java:273) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileWithPosition(Expression.java:133) at gnu.expr.IfExp.compile(IfExp.java:105) at gnu.expr.IfExp.compile(IfExp.java:41) at gnu.expr.Expression.compileWithPosition(Expression.java:133) at gnu.expr.BeginExp.compile(BeginExp.java:142) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compile(Expression.java:179) at gnu.expr.SetExp.compile(SetExp.java:273) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileWithPosition(Expression.java:133) at gnu.expr.IfExp.compile(IfExp.java:105) at gnu.expr.IfExp.compile(IfExp.java:41) at gnu.expr.Expression.compileWithPosition(Expression.java:133) at gnu.expr.BeginExp.compile(BeginExp.java:142) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.expr.LetExp.compile(LetExp.java:190) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:145) at gnu.expr.LambdaExp.compileBody(LambdaExp.java:1600) at gnu.expr.LambdaExp.compileAsMethod(LambdaExp.java:1577) at gnu.expr.LambdaExp.compileSetField(LambdaExp.java:640) at gnu.expr.LambdaExp.compile(LambdaExp.java:732) at gnu.expr.Expression.compile(Expression.java:179) at gnu.expr.SetExp.compile(SetExp.java:273) at gnu.expr.Expression.compileNotePosition(Expression.java:159) at gnu.expr.Expression.compileWithPosition(Expression.java:130) at gnu.kawa.functions.AppendValues.compile(AppendValues.java:51) at gnu.expr.ApplyExp.compile(ApplyExp.java:171) at gnu.expr.ApplyExp.compile(ApplyExp.java:110) at gnu.expr.Expression.compileWithPosition(Expression.java:148) at gnu.expr.LambdaExp.compileBody(LambdaExp.java:1600) at gnu.expr.Compilation.generateBytecode(Compilation.java:2010) at gnu.expr.Compilation.process(Compilation.java:1884) at gnu.expr.Compilation.compileToArchive(Compilation.java:988) at kawa.lib.system.compileFile(system.scm:93) at atInteractiveLevel$1.run(stdin) at gnu.expr.ModuleExp.evalModule(ModuleExp.java:293) at kawa.Shell.run(Shell.java:273) at kawa.Shell.run(Shell.java:184) at kawa.Shell.run(Shell.java:165) at kawa.repl.main(repl.java:864)
After going back a few versions (to revision 6150) the swank-kawa compiles but I get the following error when starting slime in emacs:
#|kawa:2|# connection: Socket[addr=/127.0.0.1,port=50431,localport=50430] listener: Thread[swank-listener,5,main] 1867624887 chan@11711970 #<environment user> attaching: -n 10332 20 attaching2: com.sun.jdi.ProcessAttach (defaults: pid=, timeout=) {pid=pid=-n 10332, timeout=timeout=20} closing socket: ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=50430] Exception in thread "swank" java.lang.Error: mcase failed tmp (chan@1c4a1bda (error "java.io.IOException: Invalid process identifier" "IOException" ("com.sun.tools.jdi.ProcessAttachingConnector.attach(ProcessAttachingConnector.java:86)" "swank$Mnkawa.attach(swank-kawa.scm:1566)" "swank$Mnkawa.vmAttach(swank-kawa.scm:1551)" "swank$Mnkawa.vmMonitor(swank-kawa.scm:1157)" "swank$Mnkawa.apply1(swank-kawa.scm:1155)" "gnu.expr.ModuleBody.applyN(ModuleBody.java:207)" "swank$Mnkawa.applyN(swank-kawa.scm:1972)" "gnu.expr.ModuleMethod.applyN(ModuleMethod.java:213)" "gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:214)" "gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)" "swank$Mnkawa$frame33.lambda56(swank-kawa.scm:1789)" "swank$Mnkawa$frame33.apply1(swank-kawa.scm:1787)" "gnu.expr.ModuleBody.applyN(ModuleBody.java:207)" "gnu.expr.ModuleMethod.applyN(ModuleMethod.java:213)" "gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:214)" "gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)" "swank$Mnkawa$frame32.lambda55(swank-kawa.scm:1780)" "swank$Mnkawa$frame32.apply0(swank-kawa.scm:1780)" "gnu.expr.ModuleMethod.apply0(ModuleMethod.java:183)" "runnable.run(swank-kawa.scm:1802)" "java.lang.Thread.run(Thread.java:637)"))) at swank$Mnkawa.ferror$V(swank-kawa.scm:870) at swank$Mnkawa.dispatchEvents(swank-kawa.scm:367) at swank$Mnkawa.setupServer(swank-kawa.scm:323) at swank$Mnkawa$frame.lambda2(swank-kawa.scm:315) at swank$Mnkawa$frame.apply0(swank-kawa.scm:315) at gnu.expr.ModuleMethod.apply0(ModuleMethod.java:183) at runnable.run(swank-kawa.scm:1802) at java.lang.Thread.run(Thread.java:637)
Any ideas how to fix these? (Running on OS X Leopard, Java 1.6.0_07) Thanks in advance
- Sampo
* Sampo Vuori [2008-12-09 08:30+0100] writes:
Hi,
It's great to see some support for kawa in slime.. I wanted to give it a go today but ran in a few showstoppers. With the latest kawa compiler I ran into an error which might be a compiler bug, when issuing the compile command: (compile-file "swank-kawa.scm" "swank-kawa") I get a stack trace:
java.lang.Error: popType called with empty stack
Yes, this looks like a compiler bug. But it's probably hard to create a small test case for this because the code in question is generated by a pattern matching macro which results in lots of nested IFs.
After going back a few versions (to revision 6150) the swank-kawa compiles but I get the following error when starting slime in emacs:
#|kawa:2|# connection: Socket[addr=/127.0.0.1,port=50431,localport=50430] listener: Thread[swank-listener,5,main] 1867624887 chan@11711970 #<environment user> attaching: -n 10332 20
Apparently the process id of the JVM was parsed incorrectly. On Linux this looks like: attaching: 3649 20
There is a function getpid in swank-kawa.scm which invokes "echo -n $PPID". The -n is probably a GNU extension. Luckily, it's not actually needed. So, you can delete the -n and try to compile it again.
I think that the Clojure guys use some the java.lang.management classes to get the pid. Maybe that would be more portable.
Helmut.