Sign in to follow this  
Followers 0
ds34

Script crashing returning the line number

19 posts in this topic

Sometimes I get crash reports from users that the compiled script fails, i.e.

"Line 21939 File "c:\blabla.exe"

Error; Array variable subscript badly formatted"

Clearly this is my fault by not checking the array boundaries - however, if I would check boundaries each and every time the script would be only dealing arrays rather then do any usefull work ;-).

My trouble is now to find back the line 21939, since this number is of course not matching the Scite main script Line numbers (i.e. all includes ect).

So I missed to find the possibility to create the complete au3-file from the source where the reported crash line is showing me the failing array access?

Share this post


Link to post
Share on other sites



Do you use AutoIts Obfuscator? If yes the output is saved as scriptname_obfuscated.au3. This is the input to the compiler.

So if you get a line number you could check the error in the obfuscated source.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I am using default? settings to compile:

#Tidy_Parameters=/gd /gds
#Obfuscator_Parameters=/sf /sv

I get the following output:

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /prod /in "C:\Documents and Settings\ds115\My Documents\Dokumente\AutoIt\TL1DebugBackup\v1.6\TL1DebugConsole_actual_R33_v20.au3" /autoit3dir "C:\Program Files\AutoIt3"
+>09:56:37 Starting AutoIt3Wrapper v.2.0.1.24    Environment(Language:0409  Keyboard:00000407  OS:WIN_XP/Service Pack 3  CPU:X64 OS:X86)
>Running AU3Check (1.54.19.0)  from:C:\Program Files\AutoIt3
+>09:56:40 AU3Check ended.rc:0
>Running:(3.3.4.0):C:\Program Files\AutoIt3\aut2exe\aut2exe.exe  /in "C:\Documents and Settings\ds115\My Documents\Dokumente\AutoIt\TL1DebugBackup\v1.6\TL1DebugConsole_actual_R33_v20.au3" /out "C:\Documents and Settings\ds115\Desktop\TL1DebugConsole_v2.0.exe" /nopack /icon "C:\Documents and Settings\ds115\My Documents\Dokumente\AutoIt\TL1DebugConsole\bomb.ICO" /comp 4
+>09:57:00 Aut2exe.exe ended.rc:0
>09:57:00 Performing the Program Resource Update steps:
...>Updating Program Version information.
...>Updating Program Manifest information.
...>Adding original Script source to RT_RCDATA,999 in the Output executable.
...>Adding 23 Icon(s).
+>09:57:01 Program Resource updating finished successfully.rc:0
>Running:(3.3.0.0):C:\Program Files\AutoIt3\aut2exe\upx.exe" --best --compress-icons=0 -qq "C:\Documents and Settings\ds115\Desktop\TL1DebugConsole_v2.0.exe"
  11106808 ->  10298872   92.73%    win32/pe     TL1DebugConsole_v2.0.exe
+>09:57:07 UPX Ended: rc:0
+>09:57:07 Created program:C:\Documents and Settings\ds115\Desktop\TL1DebugConsole_v2.0.exe
->09:57:07 Warning: This is an Unicode compiled script and will not run on Win9x/ME.
> Using the SVN repository of the source directory:C:\Documents and Settings\ds115\My Documents\Dokumente\AutoIt\TL1DebugBackup\v1.6\
> This file is new:TL1DebugConsole_actual_R33_v20.au3
- No changes to commit in the SVN repository.
+>09:57:08 cvsWrapper.exe ended.rc:0
>Updated the Source Version to:2.0.0.4...
>Exit code: 0    Time: 32.937

So where can I look for this file?

Share this post


Link to post
Share on other sites

Add the line

#AutoIt3Wrapper_Run_Obfuscator=y

and you will get the described obfuscated output that you can use to debug.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

In case I compile again with this obfucator=y will the line number be the same as of the original error report?

Thanks,

Daniel

BTW: Unfortunatelly the source attached to the binary in RT_RCDATA,999 is just the main script.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You can install a custom error handler in your script that would handle errors whatever you like.

@Edit - Smal example

Global $g_eventerror = 0  ; to be checked to know if com error occurs. Must be reset after handling.

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler

; Performing a deliberate failure here (object does not exist)
$oIE = ObjCreate("InternetExplorer.Application")
$oIE.visible = 1
$oIE.bogus 
if $g_eventerror then Msgbox(0,"","the previous line got an error.")

Exit 


; This is my custom error handler 
Func MyErrFunc() 
   $HexNumber=hex($oMyError.number,8) 
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
                "Number is: " & $HexNumber & @CRLF & _
                "Windescription is: " & $oMyError.windescription ) 

   $g_eventerror = 1 ; something to check for when this function returns 
Endfunc
Edited by Juvigy

Share this post


Link to post
Share on other sites

In case I compile again with this obfucator=y will the line number be the same as of the original error report?

Thanks,

Daniel

BTW: Unfortunatelly the source attached to the binary in RT_RCDATA,999 is just the main script.

The line numbers will change depending on the obfuscator options used.

In the SciTE editor please see: Help -> SciTE help -> Extra Utilities -> Obfuscator.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

You can install a custom error handler in your script that would handle errors whatever you like.

But this won't work with an array error, right?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

If Obfuscator was not active when the compiled script was made. Use:

#AutoIt3Wrapper_Run_Obfuscator=y

#Obfuscator_Parameters=/cs=0 /cn=0 /cf=0 /cv=0

That should create a merged Obfuscator code file that can be used to get close to the error region.

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

No, the custom error handler won't help with array boundary violations...

Still I did not obfuscate the original code (and I cannot reproduce the issue in my environment) so I need to create the full script that was used to generate the exe from my saved sources (main+includes).

I have all my sources so I could run compliation easily again - all I need is to fetch the file that is passed to Aut2exe.exe when pressing F7 (edit from F5) in Scite... Any idea?

Edited by ds34

Share this post


Link to post
Share on other sites

I have all my sources so I could run compliation easily again - all I need is to fetch the file that is passed to Aut2exe.exe when pressing F5 in Scite... Any idea?

Insert the lines

#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/cs=0 /cn=0 /cf=0 /cv=0
as suggestes by MvGulik in your main script and press F7 to compile the exe. In the same directory you'll find the obfuscated source.

The line numbers should be the same as no optimization is done.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

The line numbers should be the same as no optimization is done.

Not necessarily but close. Provided the source has not changed, you either on OR above the error generated code line.

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

There is a way but i have forgotten in obviously. Try searching the forums - this has been discussed before.

Share this post


Link to post
Share on other sites

Not necessarily but close. Provided the source has not changed, you either on OR above the error generated code line.

Unfortunatelly the script lines (even adjusted by 2 for the lines setting obfuscator) do not have an unsecured array access.

$blocks = StringSplit($message, @CRLF)
Local $lauf
Local $sBlockString
For $lauf = 1 To $blocks[0]
 Switch $sBlockString
    Case "M"
          $Flag = "M"
          If $endsegment = 1 Then $Flag = "M;"
<21941>   $CTAG = _StringSplit(StringStripWS($blocks[$lauf], 4), " ", " ")
          If UBound($CTAG) > 1 Then _Array2DAdd($aCtagMixedBlock, $CTAG[1] & "|" & $lauf)

This portion is old and quite proven code. $lauf is set directy set by the stringsplit function, so it appears that the "obfuscated" source is not the point of failure? Is is possible that not using the obfuscator will leave the comment lines in the code?

Share this post


Link to post
Share on other sites

Is is possible that not using the obfuscator will leave the comment lines in the code?

No. Not with a version of AutoIt that returns a line number other than -1 on a critical error.

1) If there are no multi-line breaks in the obfuscator code file. Than that is probably the line that triggered the error.

(Assuming is ok and save just because it has worked ok so far ... is what killed two space shuttle crews.) :blink:

2) Look further down in your code. (same number of lines as there are multi-line breaks in the code above it.)


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

O yea. About changing source code.

If you updated AutoIt or any of the other UDF's that you might be using after you build the exe and now. You probably going to have a hard time location the right error code. As the obfuscator file will not match what was used when you build the exe.

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Thanks,

issue resolved.

Failure found - this is line 20777 in the obfuscated script, so I probably had some change in includes.

What do you think, would it be worth an enhancement request to put the complete source into RT_RCDATA?

Share this post


Link to post
Share on other sites

Thanks,

issue resolved.

Failure found - this is line 20777 in the obfuscated script, so I probably had some change in includes.

Good to hear that. :blink:

What do you think, would it be worth an enhancement request to put the complete source into RT_RCDATA?

Not my cup of thee. So I leave this one for other forum users.

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0