Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jtcl crashes due to java exception when trying to write to a broken socket #21

Open
mjpcger opened this issue Mar 23, 2018 · 1 comment

Comments

@mjpcger
Copy link

mjpcger commented Mar 23, 2018

I have a jtcl script that uses [socket -server serverProc 23456] to create a service. After another process's connect, some data will be read and a response will be written. I use a proc like this:
proc asyncProc {fd count} {
global data
catch {
puts "Writing $data..."
incr count
puts -nonewline $fd $data
set data {}
if {$count < 100} {
after 1000 "asyncProc $fd $count"
}
}
}
The global variable data will be filled otherwise, sending data will be started via
after 1000 "asyncProc $fd 0"
where fd is the socket handle passed to the serverProc during connect.
If the client closes the connection after some seconds,
I see "Writing ...." twice in the jtcl console, then a pause of several seconds, followed by the following console output:
Exception in thread "main" tcl.lang.TclRuntimeError: PutsCmd.cmdProc() Error: IOException when putting sock2
at tcl.lang.cmd.PutsCmd.cmdProc(PutsCmd.java:99)
at tcl.lang.Parser.evalObjv(Parser.java:833)
at tcl.lang.Parser.eval2(Parser.java:1223)
at tcl.lang.Interp.eval(Interp.java:2291)
at tcl.lang.Interp.eval(Interp.java:2365)
at tcl.lang.cmd.CatchCmd.cmdProc(CatchCmd.java:50)
at tcl.lang.Parser.evalObjv(Parser.java:833)
at tcl.lang.Parser.eval2(Parser.java:1223)
at tcl.lang.Procedure.cmdProc(Procedure.java:162)
at tcl.lang.Parser.evalObjv(Parser.java:833)
at tcl.lang.Parser.eval2(Parser.java:1223)
at tcl.lang.Interp.eval(Interp.java:2291)
at tcl.lang.Interp.eval(Interp.java:2365)
at tcl.lang.cmd.AfterCmd$TimerInfo.processTimerEvent(AfterCmd.java:481)
at tcl.lang.TimerHandler.invoke(TimerHandler.java:135)
at tcl.lang.TimerEvent.processEvent(Notifier.java:803)
at tcl.lang.Notifier.serviceEvent(Notifier.java:394)
at tcl.lang.Notifier.doOneEvent(Notifier.java:538)
at tcl.lang.Notifier.processTclEvents(Notifier.java:702)
at tcl.lang.Shell.main(Shell.java:167)
This should not happen because the catch socket IO happens within the catch block, the only effect should be that no new after command should be passed to the interpreter.

@mjpcger
Copy link
Author

mjpcger commented Mar 25, 2018

Found a solution: Change line 99 of PutsCmd.java from
throw new TclRuntimeError(
to
throw new TclException(interp,
Afterwards, the error does no longer occur.
Should be fixed in next version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant