Ahk_h freezes when trying to launch a new Thread on w10 Home 1903 Topic is solved

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
kyuuuri
Posts: 336
Joined: 09 Jan 2016, 19:20

Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by kyuuuri » 10 Apr 2020, 21:05

Hello, 2 of my users have a problem with my script. I narrowed it down to "AhkThread". I gave them a simple script:

Code: Select all

#persistent
test := ahkThread("#persistent`nmsgbox test")
Compiled with /MD, version 1.1.32.0, no password used, no changes to source code, using .bin.
I also shared them my vcruntime140.dll

Nothing happens, the script is active with around 9% CPU usage like if it was stuck.

Both users have:
Edition: Windows 10 Home
Version: 1903
OS Build: 18362.720

That's the only "common" thing both users had.
I checked their updates, both fully updated except for the version change 1909.
I checked if they have VS c++ redist, both have the exact same version I have in mine, from 2005 to 2015-2019.

Is there any missing dependency there? I also tried manually adding the includes from ahk's folder, works on my pc, but doesn't work on theirs.

My laptop has Windows 10 Home, version 1909 and it works without any problems.
kyuuuri
Posts: 336
Joined: 09 Jan 2016, 19:20

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by kyuuuri » 10 Apr 2020, 21:40

1 of my users updated to:
Edition: Windows 10 Home
Version: 1909
OS Build: 18363.752
and still has the same problem.


I checked these:
  • VS Redist 2015.
  • Fully updated windows
  • vcruntime140.dll
Am I missing something I should check?
kyuuuri
Posts: 336
Joined: 09 Jan 2016, 19:20

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by kyuuuri » 10 Apr 2020, 21:58

Tested the following script:

Code: Select all

#persistent
test := ahkThread("#persistent`nmsgbox test")
msgbox % A_AhkVersion
Compiled with:
  • v1.1.32.0 AutoHotkeySC.bin \win32w
  • v1.1.32.0 AutoHotkeySC.bin \win32w_MT
  • v1.1.32.0 AutoHotkeySC.bin \win64w
  • v1.1.32.0 AutoHotkeySC.bin \win64w_MT
Results:
  1. The script is opened, using administrator or by simply double clicking it.
  2. No msgbox is shown, as soon as it reaches the line "ahkThread" it gets stuck.
  3. On x64 the process is still shown on Task Manager with around 10% CPU usage but nothing happens. On x32 the process crashes.
Systems used:
Edition: Windows 10 Home
Version: 1903
OS Build: 18362.720

Edition: Windows 10 Home
Version: 1909
OS Build: 18363.752

Both with all updates installed and VS c++ redist 2015 installed.

Tried both with my vcruntime140.dll and without it, same results
HotKeyIt
Posts: 2255
Joined: 29 Sep 2013, 18:35
Contact:

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by HotKeyIt » 11 Apr 2020, 04:59

It seems to be waiting for thread to start, can you test using LoadLibrary dll and DllCall(...\ahktextdll?
kyuuuri
Posts: 336
Joined: 09 Jan 2016, 19:20

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by kyuuuri » 11 Apr 2020, 20:06

HotKeyIt wrote:
11 Apr 2020, 04:59
It seems to be waiting for thread to start, can you test using LoadLibrary dll and DllCall(...\ahktextdll?
Hello, I tried with this code

Code: Select all

#persistent
test := ahkThread()
dllpath:=A_AhkDir "\AutoHotkey.dll"
DllCall(dllpath "\ahktextdll", "Str","MsgBox test!", "Str","","CDecl")
msgbox % A_AhkVersion
Sent them following files (All on the same folder as the .exe)
Compiled script with name "test.exe"
x64w_MD "AutoHotkey.dll"
"vcruntime140.dll"

Nothing happened, no msgbox was shown.
HotKeyIt
Posts: 2255
Joined: 29 Sep 2013, 18:35
Contact:

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by HotKeyIt » 12 Apr 2020, 03:54

Try this script:

Code: Select all

#persistent
dllpath:=A_AhkDir "\AutoHotkey.dll"
DllCall("LoadLibrary","Str",dllpath)
DllCall(dllpath "\ahktextdll", "Str","MsgBox test!", "Str","","CDecl")
msgbox % A_AhkVersion
Also, is this problem only when compiled? Try without compiling, simply send non-compiled AutoHotkey.exe including same files + AutoHotkey.ahk with above script.
kyuuuri
Posts: 336
Joined: 09 Jan 2016, 19:20

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by kyuuuri » 12 Apr 2020, 19:38

HotKeyIt wrote:
12 Apr 2020, 03:54
Try this script:

Code: Select all

#persistent
dllpath:=A_AhkDir "\AutoHotkey.dll"
DllCall("LoadLibrary","Str",dllpath)
DllCall(dllpath "\ahktextdll", "Str","MsgBox test!", "Str","","CDecl")
msgbox % A_AhkVersion
Also, is this problem only when compiled? Try without compiling, simply send non-compiled AutoHotkey.exe including same files + AutoHotkey.ahk with above script.
I followed your exact instructions.
The compiled .exe only shows the msgbox % A_AhkVersion, so the ahkThread or ahktextdll doesn't work.
The non compiled version (shared my AutoHotkey.exe located on ahk's folder) works perfectly.

Seems like there is a problem when trying to load the dll from within the exe?
HotKeyIt
Posts: 2255
Joined: 29 Sep 2013, 18:35
Contact:

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by HotKeyIt » 13 Apr 2020, 03:42

What do you see here when compiled:

Code: Select all

#persistent
dllpath:=A_AhkDir "\AutoHotkey.dll"
MsgBox % DllCall("LoadLibrary","Str",dllpath)
MsgBox % DllCall(dllpath "\ahktextdll", "Str","MsgBox test!", "Str","","CDecl")
msgbox % A_AhkVersion
kyuuuri
Posts: 336
Joined: 09 Jan 2016, 19:20

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by kyuuuri » 13 Apr 2020, 20:25

HotKeyIt wrote:
13 Apr 2020, 03:42
What do you see here when compiled:

Code: Select all

#persistent
dllpath:=A_AhkDir "\AutoHotkey.dll"
MsgBox % DllCall("LoadLibrary","Str",dllpath)
MsgBox % DllCall(dllpath "\ahktextdll", "Str","MsgBox test!", "Str","","CDecl")
msgbox % A_AhkVersion
MsgBox % DllCall("LoadLibrary","Str",dllpath): 0
MsgBox % DllCall(dllpath "\ahktextdll", "Str","MsgBox test!", "Str","","CDecl"): a blank msgbox
msgbox % A_AhkVersion: 1.1.32.00

The msgbox inside ahktextdll is never shown.
guest3456
Posts: 3162
Joined: 09 Oct 2013, 10:31

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by guest3456 » 13 Apr 2020, 20:55

kyuuuri wrote:
13 Apr 2020, 20:25
MsgBox % DllCall("LoadLibrary","Str",dllpath): 0
:arrow:
https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibrarya wrote:Return value

If the function succeeds, the return value is a handle to the module.

If the function fails, the return value is NULL
you sure you have the AutoHotkey.dll file in the right directory?

kyuuuri
Posts: 336
Joined: 09 Jan 2016, 19:20

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by kyuuuri » 13 Apr 2020, 22:46

guest3456 wrote:
13 Apr 2020, 20:55
kyuuuri wrote:
13 Apr 2020, 20:25
MsgBox % DllCall("LoadLibrary","Str",dllpath): 0
:arrow:
https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibrarya wrote:Return value

If the function succeeds, the return value is a handle to the module.

If the function fails, the return value is NULL
you sure you have the AutoHotkey.dll file in the right directory?
Yes, 100% sure. I even asked the user to send me an screenshot
Image
Image
Image
HotKeyIt
Posts: 2255
Joined: 29 Sep 2013, 18:35
Contact:

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by HotKeyIt » 14 Apr 2020, 02:48

Probably mixture of 32 and 64-bit, the dll seems to be 64-bit but does not equal the current release size. The largest dll in release is x64w = 1216 KB.
Attachments
AutoHotkey.dll.png
AutoHotkey.dll.png (22.53 KiB) Viewed 2604 times
kyuuuri
Posts: 336
Joined: 09 Jan 2016, 19:20

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by kyuuuri » 14 Apr 2020, 03:19

HotKeyIt wrote:
14 Apr 2020, 02:48
Probably mixture of 32 and 64-bit, the dll seems to be 64-bit but does not equal the current release size. The largest dll in release is x64w = 1216 KB.
If that's the case then there is something wrong with source compilación or on the pack script because I took that DLL from x64w folder and I compiled with the .bin that was on the same folder.
Also it works on all the other users (more than 90)
kyuuuri
Posts: 336
Joined: 09 Jan 2016, 19:20

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by kyuuuri » 20 Apr 2020, 07:06

HotKeyIt wrote:
14 Apr 2020, 02:48
Probably mixture of 32 and 64-bit, the dll seems to be 64-bit but does not equal the current release size. The largest dll in release is x64w = 1216 KB.
Hello, could you find anything about this? I double checked and it's x64 bit .dll, I compiled it myself and also tried the one from https://github.com/HotKeyIt/ahkdll-v1-release, but none worked.
kyuuuri
Posts: 336
Joined: 09 Jan 2016, 19:20

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by kyuuuri » 27 Apr 2020, 18:29

Tried more things, but still it will freeze the script when launching a new thread
kyuuuri
Posts: 336
Joined: 09 Jan 2016, 19:20

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by kyuuuri » 27 Apr 2020, 18:52

New user with the same problem.
Windows 10 Home
Version: 1903
Build: 18362.778

I asked him to send me a list of his updates:
Caption CSName Description FixComments HotFixID InstallDate InstalledBy InstalledOn Name ServicePackInEffect Status
http://support.microsoft.com/?kbid=4534132 DESKTOP-OE24P1O Update KB4534132 NT AUTHORITY\SYSTEM 2/14/2020
http://support.microsoft.com/?kbid=4497727 DESKTOP-OE24P1O Security Update KB4497727 4/1/2019
http://support.microsoft.com/?kbid=4515383 DESKTOP-OE24P1O Security Update KB4515383 NT AUTHORITY\SYSTEM 11/12/2019
http://support.microsoft.com/?kbid=4516115 DESKTOP-OE24P1O Security Update KB4516115 NT AUTHORITY\SYSTEM 11/17/2019
http://support.microsoft.com/?kbid=4524244 DESKTOP-OE24P1O Security Update KB4524244 NT AUTHORITY\SYSTEM 2/14/2020
http://support.microsoft.com/?kbid=4524569 DESKTOP-OE24P1O Security Update KB4524569 NT AUTHORITY\SYSTEM 11/17/2019
http://support.microsoft.com/?kbid=4528759 DESKTOP-OE24P1O Security Update KB4528759 NT AUTHORITY\SYSTEM 1/15/2020
http://support.microsoft.com/?kbid=4537759 DESKTOP-OE24P1O Security Update KB4537759 NT AUTHORITY\SYSTEM 2/14/2020
http://support.microsoft.com/?kbid=4538674 DESKTOP-OE24P1O Security Update KB4538674 NT AUTHORITY\SYSTEM 2/13/2020
http://support.microsoft.com/?kbid=4541302 DESKTOP-OE24P1O Update KB4541302 NT AUTHORITY\SYSTEM 3/17/2020
http://support.microsoft.com/?kbid=4541338 DESKTOP-OE24P1O Security Update KB4541338 NT AUTHORITY\SYSTEM 3/11/2020
http://support.microsoft.com/?kbid=4552152 DESKTOP-OE24P1O Security Update KB4552152 NT AUTHORITY\SYSTEM 4/15/2020
http://support.microsoft.com/?kbid=4549951 DESKTOP-OE24P1O Update KB4549951 NT AUTHORITY\SYSTEM 4/16/2020
kyuuuri
Posts: 336
Joined: 09 Jan 2016, 19:20

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by kyuuuri » 27 Apr 2020, 19:20

@HotKeyIt Seems like I found out how to reproduce the problem.
1. Download ahkdll-v1-release-master from: https://github.com/HotKeyIt/ahkdll-v1-release and extract on desktop
2. Create a folder called "New Folder" on Desktop.
3. Inside the folder create an script called "test.ahk"
4. Inside this script paste:

Code: Select all

#persistent
dllpath:=A_AhkDir "\AutoHotkey.dll"
MsgBox % DllCall("LoadLibrary","Str",dllpath)
MsgBox % DllCall(dllpath "\ahktextdll", "Str","MsgBox test!", "Str","","CDecl")
msgbox % A_AhkVersion
5. Open ahk2exe.ahk from the folder you just downloaded and compile test.ahk to test.exe without checking any checkbox.
6. Copy the .dll from the version you just used to "New Folder".
7. Open test.exe

Using .bin:
  • Win32: Same problem
  • Win32_MT: Same problem
  • Win64: Works
  • Win64_MT: Works
Using .exe (idk if this should be done but only for testing purposes):
  • Win32: Works BUT you get ACCESS_VIOLATION, if you press "No" to keep it running you will get all the correct msgboxes. So it works but with ACCESS_VIOLATION after the first msgbox.
  • Win32_MT: Works BUT you get ACCESS_VIOLATION, if you press "No" to keep it running you will get all the correct msgboxes. So it works but with ACCESS_VIOLATION after the first msgbox.
  • Win64: Works
  • Win64_MT: Works
If you use the x32 .dll with x64 .exe you get the same problem my users get.
If you use the x64 .dll with x32 .exe you get the same problem my users get.

But I'm sure this is not my problem because around 90% of my users can run it without any problems. The other 10% has this problem, they all downloaded from the same link.

@edit: I forgot to say, these are only tests I made on my computer. On the user computer the tests I made had no positive results. Really need help with this.
kyuuuri
Posts: 336
Joined: 09 Jan 2016, 19:20

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by kyuuuri » 28 Apr 2020, 07:02

Could narrow the issue down to this line:

Code: Select all

obj:={(""):lib:=MemoryLoadLibrary(dll=""?&ahkdll:dll="FC2328B39C194A4788051A3B01B1E7D5"?&ahkmini:dll),base:base}
The last msgbox executed is "msgbox B", seems that there is a problem with MemoryLoadLibrary.

From:

Code: Select all

ahkthread_free(obj:=""){
  static objects
  if !objects
    objects:=[]
  if (obj="")
      objects:=[]
  else if !IsObject(obj)
	return objects
  else If objects.HasKey(obj)
	objects.Remove(obj)
}
ahkthread_release(o){
  o.ahkterminate(o.timeout?o.timeout:0),MemoryFreeLibrary(o[""])
}
ahkthread(s:="",p:="",IsFile:=0,dll:=""){
  static ahkdll,ahkmini,base,functions
  msgbox A
  if !base
    base:={__Delete:"ahkthread_release"},UnZipRawMemory(LockResource(LoadResource(0,hRes:=DllCall("FindResource","PTR",0,"Str","F903E44B8A904483A1732BA84EA6191F","PTR",10,"PTR"))),SizeofResource(0,hRes),ahkdll)
    ,UnZipRawMemory(LockResource(LoadResource(0,hRes:=DllCall("FindResource","PTR",0,"Str","FC2328B39C194A4788051A3B01B1E7D5","PTR",10,"PTR"))),SizeofResource(0,hRes),ahkmini)
    ,functions:={_ahkFunction:"s==stttttttttt",_ahkPostFunction:"i==stttttttttt",ahkFunction:"s==sssssssssss",ahkPostFunction:"i==sssssssssss",ahkdll:"ut==sss",ahktextdll:"ut==sss",ahkReady:"",ahkReload:"i==i",ahkTerminate:"i==i",addFile:"ut==sucuc",addScript:"ut==si",ahkExec:"ui==s",ahkassign:"ui==ss",ahkExecuteLine:"ut==utuiui",ahkFindFunc:"ut==s",ahkFindLabel:"ut==s",ahkgetvar:"s==sui",ahkLabel:"ui==sui",ahkPause:"i==s",ahkIsUnicode:""}
  msgbox B
  obj:={(""):lib:=MemoryLoadLibrary(dll=""?&ahkdll:dll="FC2328B39C194A4788051A3B01B1E7D5"?&ahkmini:dll),base:base}
  msgbox C
  for k,v in functions
    obj[k]:=DynaCall(MemoryGetProcAddress(lib,A_Index>2?k:SubStr(k,2)),v)
  msgbox D
  If !(s+0!="" || s=0)
    obj.hThread:=obj[IsFile?"ahkdll":"ahktextdll"](s,"",p)
  msgbox E
  ahkthread_free(true)[obj]:=1 ; keep dll loadded even if returned object is freed
  msgbox F
  return obj
}
HotKeyIt
Posts: 2255
Joined: 29 Sep 2013, 18:35
Contact:

Re: Ahk_h freezes when trying to launch a new Thread on w10 Home 1903

Post by HotKeyIt » 28 Apr 2020, 18:04

I have tested on my computer and even on a fresh Win 10 Home VM without installing anything and it works fine.
Please note that in the script above one parameter was missing: MsgBox % DllCall(dllpath "\ahktextdll", "Str","MsgBox test!", "Str","","Str","","CDecl")
Post Reply

Return to “AutoHotkey_H”