Random code corruption/errors

Posted on
  • Hi

    All of a sudden I'm getting random code corruption/errors such as this:

    Uncaught Error: Field or method does not already exist, and can't create it on undefined
     at line 1 col 64
    ...deAt(1)+a.charCodeAt(2),w:a.charCodeB­t(3),h:a.charCodeAt(4),..
    

    As can be seen one of the charCodeAt statements has become charCodeBt !!!

    Another example:

     at line 1 col 26
    {return{x:a.charCodeAt(0+,y:a.charCodeAt­(1)+a.charCodeAt(2),...
    

    The closing bracket has become a + symbol.

    Maybe its just how the error is being displayed but I don't think so.

    I happen to remember someone else having similar issues - was there ever a solution?

  • Do you have a way to reproduce it? And are you using the latest firmware?

    I know a while back someone had committed some code that removed a lot of debugging checks, and as a result a few errors crept in. I've fixed those now and I was pretty sure the changes were in 1v71. I think after I posted there were no more complaints until now.

    Maybe try one of the 'git' builds and see if you still have issues?

  • Original here: http://forum.espruino.com/conversations/­256404/

    I thought I'd fixed it in 1v71, but there was never confirmation

  • I've tried the latest 1v72 but identical error.I can consistently reproduce the error even after a reset & reload and after adding debug code, its always in the same block of code but it is slightly different each time. I honestly cant see anything wrong with the code (but I've been confident about that before yet wrong!!)

    I'll try to investigate a bit more tonight.

  • I can't really think of a way any code - no matter how buggy - should be able to do that! Does it happen almost immediately, or does it take a while to happen?

    If you could email it to me it'd really be appreciated, and hopefully I can get this fixed.

  • @Gordon I've attached the partial output from a trace() after the error occurred. This time it manifested itself in some debug code. Basically a i++ became i,+ but again in the same function.
    (just noticed i<a.length also became k<a.length)

    The error is on line 917 of the file. I did a trace before the error occurred and the code was correct (I thought Closure may be corrupting something but that doesn't seem to be the case.)

    I have no issues giving you the code but it would take a lot of setup to get it running (you would need an ILI9341 with touch & wiz5500io). Maybe there is something else I could try before that?

    I'm unsure about the trace command - would it be worth doing a trace immediately before the error, then immediately after and doing a diff on them to see if there are more corruptions?

    (I copied the trace output from the console, is there a better way - maybe a simple dos command to redirect the output from a com port to a file after ECHO trace() > COM5 ?)

    I can reproduce the error in about 5 seconds of loading the program - basically a few clicks of the buttons on my ILI9341.

    I tried to reproduce the error with less code but haven't managed to yet.

    Hopefully i haven't done anything stupid since I don't want to waste your time!

    EDIT: Just ran it again - this time:

    Uncaught Error: Field or method does not already exist, and can't create it on undefined
     at line 1 col 48
    ...i=0;i<a.length;i++)console.lpg(a.char­CodeAt(i));return{x:a.c...
                                   ^
    

    log became lpg. The error always seems to be 1 character out.


    1 Attachment

  • I don't know it it's possible, but if you could try and remove the code for the touchscreen and still get it to reproduce the error (maybe using setTimeouts to call the 'touch' callback?) it'd be a huge help. I should then be able to run it on something here (I can connect a WIZnet module, and the ILI9341 is one-way so can just be left off) where I can debug it.

    The trace isn't too useful at the moment - what's happening is one of the 'JsVars' - the variable blocks - has got marked as unused even though it is used for something else, but has then got included as part of the string. Annoyingly trace() only reports the block at the start of the string, so I can't even tell which one is at fault.

    While I could give you an image with some debug code in, I can pretty much guarantee what the error message will say - and it's not going to be any use without a debugger attached.

    Does the error happen even when you're not using the WIZnet module? I guess it's possible there's a bug in that - and it would explain why I haven't reproduced anything here.

  • I've a 2nd wiznet so as a start I will swap them tonight, I'll also remove the solid state relay unit (which was switching a 240v 40w bulb but is not connected to the power supply at present). I've got a display without touch so could also swap that in.

    One odd observation - I added some extra code last night to try and move the offending function into a different memory location but the error still occurs in the same place yet the code its now about 100 lines further down the trace. I thought the error may have occurred somewhere else.

  • I've a 2nd wiznet so as a start I will swap them tonight,

    I wouldn't bother trying it - It's probably a bug in the http+wiznet code in Espruino, in which case it's nothing to do with the hardware module at all.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Random code corruption/errors

Posted by Avatar for DaveNI @DaveNI

Actions