Re: How to interrupt a running evaluation in MathLink
- To: mathgroup at smc.vnet.net
- Subject: [mg17006] Re: How to interrupt a running evaluation in MathLink
- From: rmille1 at aol.com (RMille1)
- Date: Sat, 10 Apr 1999 02:13:38 -0400
- Organization: AOL http://www.aol.com
- References: <7ek3g3$n58$1@dragonfly.wolfram.com>
- Sender: owner-wri-mathgroup at wolfram.com
Thanks. I'll give it a shot. Jens also mentioned this method. Actually, I had sort of solved this problem by wrapping "TimeConstrained['expression',2] around the expression I was passing. That way the kernel would abort itself after 2 seconds. Works like a charm. However, now I have another problem. I'm using the kernel to evaluate random expressions I'm creating for a genetic algorithm. Problem is that after about a thousand or so calculations, I crash the MathDLL.dll. It's the same error each time. Here's the dump in case you've seen it before, and know what might cause it: MATH caused an invalid page fault in module MATHDLL.DLL at 014f:1001e852. Registers: EAX=1061b97c CS=014f EIP=1001e852 EFLGS=00010206 EBX=0263fddc SS=0157 ESP=0067f77c EBP=02648790 ECX=010b5ca0 DS=0157 ESI=00000018 FS=0c57 EDX=0000002d ES=0157 EDI=06644000 GS=0000 Bytes at CS:EIP: 8b 0f 89 08 a1 5c a0 5e 10 2b c6 a3 5c a0 5e 10 Stack dump: 00000001 02648790 1001e8c4 00000014 10020acb 00000014 02648790 10002fdf 00000014 00000001 02648790 10020836 00000001 0264a628 0067f834 0263fddc Visual C++ is calling it an Access Violation. I apologize for putting that in there 'cause I know those are usually meaningless. However, it returns this same error everytime it crashes to include the line of code it crashes on (1001E852). Looking at the machine code, it looks like a regular pointer swap is going on. Anyway, I was hoping someone had a similar experience, and noticed a similar exception and figured it out. Jens suggested that it might be a problem with Unicode. However, I switched from using MLPutString() to MLPutByteString(), and even sent a message to change the $Character Encoding to ASCII when I started the kernel. Still throws the same error. So I'm thinking bug now since my code works perfectly until suddenly it trips this. My professor has a beta version of Mathematica 4 on his machine, so I'm going to try running my proggy on his system to see if that is the problem. >Hi, Interrupts over mathlink are poorly documented. There are discussions >going on about this in other threads. There is a mathlink function you can >call: MLPutMessage(link,integer) as far as I know, this is undocumented. >Symbolic constants for the second argument are defined in mathlink.h and >their names are MLInterruptMessage, MLAbortMessage etc... One of the problems >I have with this is that the kernel does not answer in the same manner when >waiting for input or evaluating. I do not know how to avoid a race conditions >that may occure. Also depending on how you start the kernel the MLPutMessage >works or fails-see another of my posts to the newsgroup (it's recent, so it >should still be there). > >Hope this helps Tobias