Menu

#1 Alan's bug: Maple blocking on incomplete input.

open
nobody
None
5
2000-12-22
2000-12-22
No

Hi Andrew,
Here's a bit of a puzzle.
The MapleInput applet (code attached) works fine with any correct Maple
command, and produces an appropriate error message for the disabled read
command; but on malformed input such as "2o2;" or "2+3"(without the
";"), it just hangs. And what's worse, it seems to be progressively
using up resources or something (in a way not displayed on the
JavaConsole) so that after a couple more mouse-clicks the browser dies!
I've tried spliting the nativeEvaluate command, but that doesn't seem to
make any difference.
Any ideas?

-- Alan

Alan Cooper (acooper@langara.bc.ca , http://www.langara.bc.ca/~acooper\)
Dep't of Mathematics and Statistics (http://www.langara.bc.ca/mathstats)

Langara College (http://www.langara.bc.ca )
100 W 49th Ave. Vancouver BC
Canada V5Y2Z6 Tel(604)323-5676,Fax(604)323-5555
=======================================================================

//MapleInput.java
/**
* This applet tests the javamath ProxyCAS
*/

package gex;

import java.applet.*;
import java.awt.*;import java.awt.event.*;
import javamath.server.proxycas.*;

public class MapleInput extends Applet implements ActionListener {

TextField theInput;
TextArea theOutput,theError;
Label inputLabel,outputLabel,errorLabel;
ProxyCASession maple;

public MapleInput() {
super(); setSize(800,600); setLayout(null);
setBackground(new Color(255,0,255));
theInput = new TextField();
theInput.setSize(700,50);
theInput.setLocation(50,70);
add(theInput);
theInput.addActionListener(this);
inputLabel=new Label("Enter a Maple command here");
inputLabel.setBounds(50,50,200,20); add(inputLabel);

theOutput = new TextArea(6,40);
theOutput.setSize(700,150);
theOutput.setLocation(50,190);
add(theOutput);
outputLabel=new Label("Maple Output Area:");
outputLabel.setBounds(50,170,100,20); add(outputLabel);

theError = new TextArea(4,40);
theError.setSize(700,100);
theError.setLocation(50,360);
add(theError);
errorLabel=new Label("Maple Error Messages:");
errorLabel.setBounds(50,170,100,20); add(errorLabel);

}

public void init() {repaint();

ProxyCAServer theServer=new
ProxyCAServer("http://dev.camel.math.ca/ProxyCAS");
maple=theServer.createSession("Maple");

}

public void actionPerformed(ActionEvent a) {
String result="nothing happened",errormessage="nothing wrong";
try {
//result=maple.nativeEvaluate(theInput.getText());
maple.sendNativeCommand(theInput.getText());
result=maple.getNativeOutput();
errormessage=maple.getNativeError();
}catch(Exception e){e.printStackTrace();}
theOutput.setText(result);theError.setText(errormessage);
}

}
Subject:
RE: MapleInput
Date:
Fri, 15 Dec 2000 08:36:32 +0100
From:
"Manfred Riem" <mriem@win.tue.nl>
To:
"'Andrew Solomon'" <andrew@illywhacker.net>, "'Alan Cooper'" <acooper@langara.bc.ca>
CC:
"'Craig A. Struble'" <cstruble@vt.edu>

Hi Andrew,

If I remember correctly we had a similar problem with our
Coq/CoCoA implementation as a server. You have 2 options,
either specify a timeout value upon reading, using a separate
thread to read which you kill after that timeout, or
(and that's what we used) append a special command at the end
of every input that generates a specific output at the end.

Hope I explained this clear enough, it's a bit early in the
morning after a long day yesterday.

Regards,

Manfred.

> -----Original Message-----
> From: andrew@localhost.localdomain
> [mailto:andrew@localhost.localdomain]On Behalf Of Andrew Solomon
> Sent: vrijdag 15 december 2000 7:48
> To: Alan Cooper
> Cc: Manfred Riem; Craig A. Struble
> Subject: Re: MapleInput
>
>
> I'm cc:'ing this to Manfred Reim (RIACA, Eindhoven) and Craig
> in the hope that they might have some ideas...
>
> The applet in question is at:
> http://dev.camel.math.ca/~acooper/projects/MapleInput.htm
>
> Alan Cooper wrote:
> >
> > Hi Andrew,
> > Here's a bit of a puzzle.
> > The MapleInput applet (code attached) works fine with any
> correct Maple
> > command, and produces an appropriate error message for the
> disabled read
> > command; but on malformed input such as "2o2;" or "2+3"(without the
> > ";"), it just hangs. And what's worse, it seems to be progressively
> > using up resources or something (in a way not displayed on the
> > JavaConsole) so that after a couple more mouse-clicks the
> browser dies!
> > I've tried spliting the nativeEvaluate command, but that
> doesn't seem to
> > make any difference.
> > Any ideas?
>
> hi Alan,
>
> Things should be back to the way they were on dev (I've
> restarted the web server too).
>
> for the moment, I don't see a solution. The problem is called
> "blocking".
> The idea is: you say
> sendCommand(command)
> and then
> getNativeOutput()
>
> but if the command is incomplete, then Maple is still sitting
> around waiting
> for more input. That's how getNativeOutput works - it waits
> until the "ready for more input"
> signal from Maple, and of course, Maple never gives it
> because it isn't ready.
>
> I'm going to ask the Maple folks about it, but one rather
> boring approach you could
> take is to try to do some checking to ensure that command is
> a complete command.
> Not very satisfactory, I know. Let's think on it for a bit.
>
> I could look at adding a flag to the API along the lines of
> mapleprocess.ready() which is true iff it is ready for more
> input or ready
> to divulge the output. If it isn't true, then you shouldn't
> call getNativeOutput().
> The problem there is that trying to do this might in itself
> encounter the same problem.
>
> Andrew
>
> >
> > //MapleInput.java
> > /**
> > * This applet tests the javamath ProxyCAS
> > */
> >
> > package gex;
> >
> > import java.applet.*;
> > import java.awt.*;import java.awt.event.*;
> > import javamath.server.proxycas.*;
> >
> > public class MapleInput extends Applet implements ActionListener {
> >
> > TextField theInput;
> > TextArea theOutput,theError;
> > Label inputLabel,outputLabel,errorLabel;
> > ProxyCASession maple;
> >
> >
> >
> >
> > public MapleInput() {
> > super(); setSize(800,600); setLayout(null);
> > setBackground(new Color(255,0,255));
> > theInput = new TextField();
> > theInput.setSize(700,50);
> > theInput.setLocation(50,70);
> > add(theInput);
> > theInput.addActionListener(this);
> > inputLabel=new Label("Enter a Maple command here");
> > inputLabel.setBounds(50,50,200,20); add(inputLabel);
> >
> > theOutput = new TextArea(6,40);
> > theOutput.setSize(700,150);
> > theOutput.setLocation(50,190);
> > add(theOutput);
> > outputLabel=new Label("Maple Output Area:");
> > outputLabel.setBounds(50,170,100,20); add(outputLabel);
> >
> > theError = new TextArea(4,40);
> > theError.setSize(700,100);
> > theError.setLocation(50,360);
> > add(theError);
> > errorLabel=new Label("Maple Error Messages:");
> > errorLabel.setBounds(50,170,100,20); add(errorLabel);
> >
> >
> > }
> >
> > public void init() {repaint();
> >
> > ProxyCAServer theServer=new
> > ProxyCAServer("http://dev.camel.math.ca/ProxyCAS");
> > maple=theServer.createSession("Maple");
> >
> > }
> >
> > public void actionPerformed(ActionEvent a) {
> > String result="nothing happened",errormessage="nothing wrong";
> > try {
> > //result=maple.nativeEvaluate(theInput.getText());
> > maple.sendNativeCommand(theInput.getText());
> > result=maple.getNativeOutput();
> > errormessage=maple.getNativeError();
> > }catch(Exception e){e.printStackTrace();}
> > theOutput.setText(result);theError.setText(errormessage);
> > }
> >
> >
> >
> > }
> >
>
Subject:
Re: MapleInput
Date:
Thu, 14 Dec 2000 23:50:25 -0800
From:
Alan Cooper <acooper@langara.bc.ca>
Organization:
Langara College Department of Mathematics and Statistics
To:
Andrew Solomon <andrew@illywhacker.net>
References:
1 , 2

With regard to the missing terminator, three thoughts.
One is that Windows Maple accepts input split over several lines which it
concatenates and
processes on receiving a ';' , so perhaps sendNativeCommand might do this also.
Another is that it might make sense to initiate a thread for the processing so
that, if Maple
does block, the whole system doesn't get stalled.
And a third is that it might make sense (with or without a separate thread) to
implement a
timeout.

With regard to the malformed input, would running getNativeError before
getNativeOutput produce
a message that could prompt the program to not call (and get hung by)
getNativeOutput? If so, it
might be a good idea to incorporate such a check in getNativeOutput (or its
server-side version)
so that the user programmer could be shielded from actually having to do it.

Andrew Solomon wrote:

> I'm cc:'ing this to Manfred Reim (RIACA, Eindhoven) and Craig
> in the hope that they might have some ideas...
>
> The applet in question is at:
> http://dev.camel.math.ca/~acooper/projects/MapleInput.htm
>

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.