SysGetIPAddresses() causes Invalid memory read/write. Topic is solved

Report problems with documented functionality
Banaanae
Posts: 34
Joined: 19 Feb 2024, 04:08
Contact:

SysGetIPAddresses() causes Invalid memory read/write.

Post by Banaanae » 17 Mar 2024, 03:01

When using the example

Code: Select all

addresses := SysGetIPAddresses()
msg := "IP addresses:`n"
for n, address in addresses
    msg .= address "`n"
MsgBox msg
[Mod edit: Added [code][/code] tags and replaced ```. Please use them yourself when posting code!]

I get this error
image.png
image.png (10.07 KiB) Viewed 943 times
Using Win 11, also happens
Spoiler
Attachments
image.png
image.png (22.84 KiB) Viewed 943 times
User avatar
gregster
Posts: 9224
Joined: 30 Sep 2013, 06:48

Re: SysGetIPAddresses() causes Invalid memory read/write.

Post by gregster » 17 Mar 2024, 03:06

No problem here - with v2 on Win11.
User avatar
lmstearn
Posts: 714
Joined: 11 Aug 2016, 02:32
Contact:

Re: SysGetIPAddresses() causes Invalid memory read/write.

Post by lmstearn » 20 Mar 2024, 01:41

In v1, using the posted code gets:
Error: Call to nonexistent function.
Specifically: SysGetIPAddresses()

Line#
---> 001: addresses := SysGetIPAddresses()
002: msg := "IP addresses:
"
003: For n,address in addresses
004: msg .= address "
"
005: MsgBox,msg
006: Exit

The program will exit.
Not using a v2.1X alpha btw?
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
User avatar
gregster
Posts: 9224
Joined: 30 Sep 2013, 06:48

Re: SysGetIPAddresses() causes Invalid memory read/write.

Post by gregster » 20 Mar 2024, 08:29

lmstearn wrote:
20 Mar 2024, 01:41
In v1, using the posted code gets:
Error: Call to nonexistent function.
Specifically: SysGetIPAddresses()
Of course, this function doesn't exist in v1; and I don't see anything related in the SysGet docs.
According to the error message, the v1 code just seems to use the line Msgbox % A_IPAddress1 or similar. Again, no problems here (IPv4 addresses behind a router).
With neither of the four built-in variables. (Compare https://www.autohotkey.com/docs/v1/Variables.htm#IPAddress)

v2 docs say explicitly "only IPv4 is supported" but could that cause "Invalid memory read/write"?!?
User avatar
lmstearn
Posts: 714
Joined: 11 Aug 2016, 02:32
Contact:

Re: SysGetIPAddresses() causes Invalid memory read/write.

Post by lmstearn » 21 Mar 2024, 01:51

Could be, AHK uses Winsock.h only, in there:
#ifdef IPV6STRICT
#error WINSOCK2 required.
in_addr is for ipv4 only. :(
Toggled off the ethernet to test, the IP now loops back to localhost, no crash either.
Quite a rabbit hole with v6, this seems to be most accepted on SO.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
Banaanae
Posts: 34
Joined: 19 Feb 2024, 04:08
Contact:

Re: SysGetIPAddresses() causes Invalid memory read/write.

Post by Banaanae » 21 Mar 2024, 05:43

I have a IPv4 address
("curl ident.me" via cmd returns an ipv4)

Also tried a vpn and that didn't work
Banaanae
Posts: 34
Joined: 19 Feb 2024, 04:08
Contact:

Re: SysGetIPAddresses() causes Invalid memory read/write.

Post by Banaanae » 21 Mar 2024, 05:54

Reread docs and made a mistake (can't edit post in review so new post)
This function only returns the IP addresses of the computer's network adapters.
Ran "ipconfig /all" via command which says there's one 192.168.X.X address under "Wireless LAN adapter Wi-Fi:"

Sorry if the reason is now obvious, networking isn't my strongsuit
lexikos
Posts: 9780
Joined: 30 Sep 2013, 04:07
Contact:

Re: SysGetIPAddresses() causes Invalid memory read/write.  Topic is solved

Post by lexikos » 22 Mar 2024, 20:22

A_IPAddressX and SysGetIPAddresses weren't designed to handle failure. v2.0.12 fixes this.

However, whatever condition was causing it to fail will likely still do so; you'll just get an empty array instead of a Critical Error. If you are not having issues in other software, I would suggest looking at firewall/security software, or other software related to networking.
Post Reply

Return to “Bug Reports”