Author Topic: After a script error cannot compile it anymore  (Read 4799 times)

Offline gvanhau

  • PixInsight Old Hand
  • ****
  • Posts: 345
After a script error cannot compile it anymore
« on: 2011 August 25 18:13:01 »
Hello
I was building a script, using as base the drawsignature script. (my first script).

when the script was doing more or less what I wanted, and
after cleaning up part of the original script, y tried to execute it again.
The system hanged up, so I had to reset the computer.

After that, I can not even compile the script, I get an out of memory error.
I tried to reset the script engine but nothing helps.

What can be so bad in a script that it can not be compiled?

regards
Geert


Geert Vanhauwaert

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Re: After a script error cannot compile it anymore
« Reply #1 on: 2011 August 25 18:14:29 »
More importantly, what can be so bad about a script that it requires a system reset? I mean that's really quite unheard of. What OS?
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline gvanhau

  • PixInsight Old Hand
  • ****
  • Posts: 345
Re: After a script error cannot compile it anymore
« Reply #2 on: 2011 August 25 18:48:29 »
Hello
Operating sytem is windows 7 64bit, 
system has 8Gb ram and 4 core phenom processor.

I copied the script to another file, jut in case, but still get out of memory when trying to compile.

regards geert



Geert Vanhauwaert

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Re: After a script error cannot compile it anymore
« Reply #3 on: 2011 August 25 18:57:16 »
Hi Geert,

I think Juan would like to see the script to see if he can reproduce the problem. Ideally you'd make the script as small as possible while still producing the problem.
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline gvanhau

  • PixInsight Old Hand
  • ****
  • Posts: 345
Re: After a script error cannot compile it anymore
« Reply #4 on: 2011 August 25 19:24:32 »
Hello

I already found out what was causing the problem:

during cleanup, I erased a bracket at the end of the class definition.
so the there was an unbalance of brackets in the script.

after restoring the missing bracket, everything went ok.

I think  that the script compiler was reading past  the end of the file, searching the ending bracket,
and so generating the memory fault.

Regards
Geert
Geert Vanhauwaert

Offline Nocturnal

  • PixInsight Jedi Council Member
  • *******
  • Posts: 2727
    • http://www.carpephoton.com
Re: After a script error cannot compile it anymore
« Reply #5 on: 2011 August 25 20:44:05 »
Hi Geert,

that is very interesting. Let's see if Juan can reproduce this problem. I hope it's something he can fix rather than something that's in the code he's re-using.
Best,

    Sander
---
Edge HD 1100
QHY-8 for imaging, IMG0H mono for guiding, video cameras for occulations
ASI224, QHY5L-IIc
HyperStar3
WO-M110ED+FR-III/TRF-2008
Takahashi EM-400
PIxInsight, DeepSkyStacker, PHD, Nebulosity

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: After a script error cannot compile it anymore
« Reply #6 on: 2011 August 28 03:23:47 »
Hi Geert,

This looks like a serious bug in the SpiderMonkey 1.8.5 JavaScript compiler. I haven't seen anything similar to this before (well, not at least since the wonderful times of the 6502, 8088, 68000, and the like :))

WARNING: This bug is potentially dangerous, especially on 64-bit systems. Do not try to reproduce this bug unless you have full knowledge of what you are doing. You probably will have to reset or switch off your machine if you experience this bug.

The bug is easily reproducible. The following script causes it each time it is compiled:

Code: [Select]
for ( var i = 0; i < 100; ++i )
{
   let a = i;

Indeed, the problem is in the lacking right bracket at the end of the script. Apparently, when the compiler tries to compile the above code it requests allocation of a huge amount of memory, which leads to generation of a monster swap disk file. On my Linux laptop (Fedora 14 x86_64) I cannot stop the process by any means and I have to switch the machine off. This bug behaves just as a denial-of-service attack.

Please be careful with this problem when writing and compiling scripts. I'll try to contact the Mozilla JS team to see what I can find to solve this issue as soon as possible. Sorry for the inconvenience.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: After a script error cannot compile it anymore
« Reply #7 on: 2012 October 05 01:47:55 »
This bug has been fixed in the incoming 1.8 version of PixInsight, as shown on this video:

http://forum-images.pixinsight.com/20121005/bracket-bug-fixed.avi

The bug has been fixed "automagically" when we have integrated version 1.8.7 of the SpiderMonkey JavaScript engine in PI 1.8.

Sorry for the delay in solving this problem. I ask just for a bit of patience until we release PI 1.8. In the meanwhile, you know, keep all your brackets closed... :)
Juan Conejero
PixInsight Development Team
http://pixinsight.com/