Post Reply 
CAS program corrupts itself
08-10-2014, 01:30 PM (This post was last modified: 08-10-2014 05:01 PM by Joe Horn.)
Post: #1
CAS program corrupts itself
The following CAS program seems to corrupt itself when run. If you attempt the following, be sure to backup your Prime first, for you will almost certainly lose everything.

On the hardware Prime, rev 6030, create this CAS program called SAVAGE:

Code:
(x)->BEGIN
 LOCAL A,B;
  A:=1;
  FOR B FROM 1 TO 2499 DO
  A:=tan(atan(e^(ln(√(A*A)))))+1;
  PRINT(A);
  END;
  RETURN(A);
END;

In CAS, in exact mode, type SAVAGE(0) Enter. You will see the counter march down the screen, slowing down as expected. After a few seconds, press On to abort the run. One of the following will probably be observed:

(1) The program's FOR line will have been changed to this:

FOR B FROM 1 TO 4999 STEP "Stopped by user interruption. Error: Bad Argument Value" DO

or (2) the FOR line will have been changed to this

FOR B FROM 1 DOWNTO 4999 DO

or (3) editing the program (to see its contents) will warmstart, or Prime will simply refuse to let you edit it.

Since memory is being corrupted, the above are probably not the only possible symptoms. A complete recovery from a backup is recommended to undo the corruption.

The emulator (rec 6031) acts slightly differently with this program. I can't wrap my head around what's happening there.

EDIT: After experimenting, it seems that pressing On to interrupt any FOR loop in a CAS program corrupts the FOR statement.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
08-10-2014, 09:29 PM
Post: #2
RE: CAS program corrupts itself
Is it just me, or is the bloom off this rose...etc.

Ha!


(08-10-2014 01:30 PM)Joe Horn Wrote:  The following CAS program seems to corrupt itself when run. If you attempt the following, be sure to backup your Prime first, for you will almost certainly lose everything.

On the hardware Prime, rev 6030, create this CAS program called SAVAGE:

Code:
(x)->BEGIN
 LOCAL A,B;
  A:=1;
  FOR B FROM 1 TO 2499 DO
  A:=tan(atan(e^(ln(√(A*A)))))+1;
  PRINT(A);
  END;
  RETURN(A);
END;

In CAS, in exact mode, type SAVAGE(0) Enter. You will see the counter march down the screen, slowing down as expected. After a few seconds, press On to abort the run. One of the following will probably be observed:

(1) The program's FOR line will have been changed to this:

FOR B FROM 1 TO 4999 STEP "Stopped by user interruption. Error: Bad Argument Value" DO

or (2) the FOR line will have been changed to this

FOR B FROM 1 DOWNTO 4999 DO

or (3) editing the program (to see its contents) will warmstart, or Prime will simply refuse to let you edit it.

Since memory is being corrupted, the above are probably not the only possible symptoms. A complete recovery from a backup is recommended to undo the corruption.

The emulator (rec 6031) acts slightly differently with this program. I can't wrap my head around what's happening there.

EDIT: After experimenting, it seems that pressing On to interrupt any FOR loop in a CAS program corrupts the FOR statement.
Find all posts by this user
Quote this message in a reply
08-11-2014, 07:07 AM
Post: #3
RE: CAS program corrupts itself
Can you interrupt if you suppress the PRINT statement?
Find all posts by this user
Quote this message in a reply
08-11-2014, 12:40 PM
Post: #4
RE: CAS program corrupts itself
What an appropriate name for the program, SAVAGE. The PRINT command may be the culprit, as it may not be designed for CAS programs.
Visit this user's website Find all posts by this user
Quote this message in a reply
08-11-2014, 04:54 PM (This post was last modified: 08-11-2014 04:56 PM by Joe Horn.)
Post: #5
RE: CAS program corrupts itself
(08-11-2014 12:40 PM)Eddie W. Shore Wrote:  The PRINT command may be the culprit, as it may not be designed for CAS programs.

No, it happens no matter what's in the loop. Even this gets corrupted:
Code:

(x)->BEGIN  
  FOR x FROM 1 TO 10000000000 DO x:=x; 
  END; 
  RETURN(x);  
END;

When interrupted by pressing On, the above turns into this:
Code:

(x)->BEGIN  
  FOR x FROM 1 TO 10000000000 STEP "Stopped by user interruption. Error: Bad Argument Value" DO x:=x; 
  END;;  
  RETURN(x);  
END;

What really scares me is this: delete the corrupted program, re-create it from scratch, exit the program editor, and before even running it, go back and look at it... it will already be corrupted (usually with the TO turned into DOWNTO). So this bug not only corrupts the running program, but corrupts programs that haven't even been written yet! It's a tunneling tachyon emitter! Vewwy, vewwy scawwy!

Q: What do zombie tunneling tachyons eat?
A: Branes!

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
10-20-2014, 03:25 PM
Post: #6
RE: CAS program corrupts itself
It seems that the corruption goes the other way around also: for example
FOR k FROM n DOWNTO 1 DO is rewritten thus FOR k FROM n TO 1 DO
Find all posts by this user
Quote this message in a reply
10-20-2014, 06:08 PM
Post: #7
RE: CAS program corrupts itself
Hello prime fans,

I have no prime nor I use the emulator.
The hp 50g use in his FOR loops counter variables which are reals (the start and end value can be integer, too). Maybe the FOR loops work with start and end values 1.0 TO 2499.0 . Although it's a contradiction to CAS mode...

... only a sneaking suspicion...

greetings peaceglue
Find all posts by this user
Quote this message in a reply
10-05-2015, 07:45 PM
Post: #8
RE: CAS program corrupts itself
Can you confirm: does this only happen if the FOR is interrupted?
Or to put it another way, is it safe to run SAVAGE in CAS provided one is patient enough to wait for it to complete?

Stephen Lewkowicz (G1CMZ)
ANDROID HP PRIME APP NO LONGER WORKS OFFLINE?
Visit this user's website Find all posts by this user
Quote this message in a reply
10-06-2015, 06:05 AM
Post: #9
RE: CAS program corrupts itself
(10-05-2015 07:45 PM)StephenG1CMZ Wrote:  Can you confirm: does this only happen if the FOR is interrupted?
Or to put it another way, is it safe to run SAVAGE in CAS provided one is patient enough to wait for it to complete?

Please note that this thread is obsolete. The bug it refers to has been gone for a long time; it may have been removed when the #cas and #end structure was introduced. No need to worry about it any more. (At least it doesn't happen on my Prime with updated firmware).

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
10-21-2015, 08:59 PM (This post was last modified: 10-21-2015 10:15 PM by StephenG1CMZ.)
Post: #10
RE: CAS program corrupts itself
I tried to implement this, but the only result I got was savage(0) or 0 instantly.
Then I saw your comment about a new cas syntax, so I deleted my first Cas code to try again. SAVAGE no longer shows in the directory.

I tried to create SAVAGE again and I get an error saying that a program called savage already exists.

I'm a novice at Cas so maybe I did something ridiculous rather than recreate some corruption.
I'm using the Android emulator.

Any suggestions on how to get rid of this invisible and undeletable savage program?
(I've recently cleared all data, so could easily do so again).

Update: I also seem to be getting a lot of Network Connection Unavailable messages lately - although the browser connects OK.

Stephen Lewkowicz (G1CMZ)
ANDROID HP PRIME APP NO LONGER WORKS OFFLINE?
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)