Jump to content

Crash after upgrading to 3.3.10.2


mojomatt
 Share

Recommended Posts

Hi,  Prior to upgragind to version 3.3.10.2 this snippet of code worked but now it crashes.  Any idea what's going on?

$objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20


$colConfigItems = $objWMIService.ExecQuery("SELECT ipaddress FROM Win32_NetworkAdapterConfiguration", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

MsgBox(0,"","debug1")

For $objConfigItem In $colConfigItems ; objects from Win32_NetworkAdapterConfiguration

MsgBox(0,"","debug2")
    ; Error happens on the next line...
    MsgBox(0,"", $objConfigItem.ipaddress(0))
Next
Link to comment
Share on other sites

What do you mean by crash?

Can you give us more information by posting the content of the SciTE output pane?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

If you remove the 0 inside the parentheses from this statement, it doesn't crash but also doesn't return anything.

MsgBox(0,"", $objConfigItem.ipaddress(0))
Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

The popup dialog has this text:

"AutoIT v3 Script has stopped working

A problem caused the program to stop working correctly.  Please close the program."

 

Here's the output from SciTE:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:Users<userid>Desktoptesttest.au3" /UserParams   
+>10:34:04 Starting AutoIt3Wrapper v.2.1.4.0 SciTE v.3.3.7.0 ;  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0409  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64)
>Running AU3Check (3.3.10.2)  from:C:Program Files (x86)AutoIt3
+>10:34:04 AU3Check ended.rc:0
>Running:(3.3.10.2):C:Program Files (x86)AutoIt3autoit3.exe "C:UsersU0073615Desktoptesttest.au3"   
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
!>10:34:07 AutoIt3.exe ended.rc:-1073741819
>Exit code: -1073741819    Time: 4.214
 

Edited by mojomatt
Link to comment
Share on other sites

FWIW... The above code is just a porting of this vbscript code...

 

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

Set objWMIService = GetObject("winmgmts:.rootCIMV2")
Set colItems = objWMIService.ExecQuery("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
  wscript.echo objItem.IPAddress(0)
Next

Edited by mojomatt
Link to comment
Share on other sites

Try this...

Local $rtn = _GetIPAddresses()
MsgBox(0, '', $rtn)


Func _GetIPAddresses($sComputer = @ComputerName)

    Local $objWMI = ObjGet('winmgmts:\\' & $sComputer & '\root\CIMV2')
    Local $objClass = $objWMI.InstancesOf('Win32_NetworkAdapterConfiguration Where IPEnabled="True"')

    Local $array, $string = ''

    For $objItem In $objClass
        $array = $objItem.IPAddress
        If IsArray($array) Then
            $string &= ',' & $array[0]
        EndIf
    Next

    Return StringTrimLeft($string, 1)

EndFunc

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

It looks like with version 3.3.10.2, you cannot access elements of arrays that may or may not be returned by the objects, like you could in 3.3.8.1, unless you save to a variable and check its type.  Similar to ripdad above, here is your example with a workaround.  

$objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20


$colConfigItems = $objWMIService.ExecQuery("SELECT ipaddress FROM Win32_NetworkAdapterConfiguration", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

MsgBox(0,"","debug1")

For $objConfigItem In $colConfigItems ; objects from Win32_NetworkAdapterConfiguration

    MsgBox(0,"","debug2")
    $aIPAddress = $objConfigItem.ipaddress
    If IsArray($aIPAddress) Then
        MsgBox(0,"", $aIPAddress[0])
    EndIf
Next

This is a script breaking change, but it is not listed.  

 

Adam

Edited by AdamUL
Link to comment
Share on other sites

Yes Ripdad's script is a workaround but it still doesn't address why AutoIT hard crashes under the error condition in v3.3.10.2  whereas it didn't in earlier versions.  The issue appears to be the value of $objItem.IPAddress(0) is null and the interpreter can't handle that which is likely a bigger issue since this is only one proof of concept example of the crash.  It appears to crash whenever an array value returned from a WMI query is null.  The same crash occurrs with DefaultIPGateway, DNSDomainSuffixSearchOrder, DNSServerSearchOrder and other array values.

Here are the problem details as returned by Windows...

Problem signature:

Problem Event Name: APPCRASH

Application Name: autoit3.exe

Application Version: 3.3.10.2

Application Timestamp: 52c196bd

Fault Module Name: autoit3.exe

Fault Module Version: 3.3.10.2

Fault Module Timestamp: 52c196bd

Exception Code: c0000005

Exception Offset: 0004b79d

OS Version: 6.3.9600.2.0.0.272.7

Locale ID: 1033

Additional Information 1: 5861

Additional Information 2: 5861822e1919d7c014bbb064c64908b2

Additional Information 3: 01d7

Additional Information 4: 01d7340064827245f2249cd1f1a7c264

Read our privacy statement online:

http://go.microsoft.com/fwlink/?linkid=280262

If the online privacy statement is not available, please read our privacy statement offline:

C:Windowssystem32en-USerofflps.txt

Here is AutoIT's exit code:

Exit code: -1073741819    Time: 57.541

Here is a quick sample to reproduce the issue...

_GetIPAddresses()

Func _GetIPAddresses($sComputer = @ComputerName)

    Local $objWMI = ObjGet('winmgmts:\\' & $sComputer & '\root\CIMV2')
    Local $objClass = $objWMI.InstancesOf('Win32_NetworkAdapterConfiguration')

    For $objItem In $objClass
       MsgBox(0,"",$objItem.IPAddress(0))
    Next

EndFunc
Link to comment
Share on other sites

  • Administrators

I've found the relevant bits of code where this occurs. COM is returning an S_OK result code with a variant set to VT_ERROR. When that variant gets copied the code was missing something. I've fixed that now so that it assigns the result a copy of the VT_ERROR COM object. That at least gives the same output as 3.3.8.1.  Wondering if I should assign it as an AutoIt null keyword or VT_NULL instead. Or even kick off the COM error handler. 

Link to comment
Share on other sites

Yes, that was the problem. When VARIANT is VT_ERROR and scode is 0 (actually and probably anything except DISP_E_PARAMNOTFOUND) you should convert it to empty/uninitialized Variant. That's empty string in AutoIt. Don't consider Null (that's reserved for VT_NULL) and don't error out, if it was error it would be handled before getting there.

edit: I see you checked what VBS is doing. Maybe Null isn't bad idea... have to think about it.

Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

VBS version:

Set objWMIService = GetObject( "winmgmts://./root/CIMV2" )
Set colItems      = objWMIService.ExecQuery("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration")

For Each objItem In colItems
    WScript.Echo TypeName(objItem.IPAddress)
    If IsArray(objItem.IPAddress) Then
        If UBound(objItem.IPAddress) = 0 Then
            strIP = "IP Address: " & objItem.IPAddress(0)
        Else
            strIP = "IP Addresses: " & Join(objItem.IPAddress, "    ")
        End If
        WScript.Echo strIP
    End If
Next
JS:

var objWMIService = GetObject("winmgmts:\\\\.\\root\\CIMV2");
var colItems = objWMIService.ExecQuery("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration");

var enumItems = new Enumerator(colItems);
for (; !enumItems.atEnd(); enumItems.moveNext())
{
    var objItem = enumItems.item();
    try
    {
        WScript.Echo("IPAddress: " + (objItem.IPAddress.toArray()).join("    "));
    }
    catch(e)
    {
        WScript.Echo(objItem.IPAddress);
    }
}
Maybe it's really the best to go with Null then, no matter what I like or don't :D.

♡♡♡

.

eMyvnE

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...