As testing showed this bug somewhat differs from my previous ticket, I post it again with the correct description:
When using twapi::get_process_name $pid the following error is raised: "Only part of a Read Process Memory or Write Process Memory request was completed" while executing "EnumProcessModules $htprocess".
Details are described here http://msdn.microsoft.com/en-us/library/ms682631.aspx (msdn on EnumProcessModules function).
"If this function is called from a 32-bit application running on WOW64, it can only enumerate the modules of a 32-bit process. If the process is a 64-bit process, this function fails and the last error code is ERROR_PARTIAL_COPY (299)."
The following example shows the problem. It starts notepad and stops it. More or less every second time it produces the mentioned error (tcl 8.5.2, twapi 3.1.17 on windows 7 x64).
package require twapi
#notepad will be started in 64 bit on x64 machines
set cmd twapi::create_process
lappend cmd [file join $::env(windir) notepad.exe]
set e [catch $cmd result]
set pid [lindex $result 0]
#no problem here...
for {set x 0} {$x<100} {incr x} {
set procname [twapi::get_process_name $pid]
}
tk_dialog .dia1 "no problem" "$procname, $::tcl_platform(pointerSize)" info 0 Ok
set chk 0
after 1000 {set ::chk 1}
vwait chk
catch {twapi::end_process $pid}
#...but here (sometimes)
for {set x 0} {$x<100} {incr x} {
set procname [twapi::get_process_name $pid]
}
tk_dialog .dia2 "problem" "$procname" info 0 Ok
Anonymous
I understand you are on a 64-bit system. What's not clear to me is whether you are using a 32-bit Tcl or a 64-bit version ? If the former, then this is a Windows limitation and only solution is to use 64-bit Tcl (and twapi). Please clarify
/Ashok
Sorry for the long delay.
I am using a 64bit tcl (Tclkit by equi4 version 8.5.2 x86 (64b) from here: http://equi4.com/tclkit/download.html to be specific). I could reproduce the same behaviour with activetcl.
Is there any debugging information I could provide?
I also don't quite understand why you are trying to get the process name after terminating the process ?
Are you saying that the problem occurs when trying to get the name of a process that is currently being terminated ?
Thanks
/Ashok
Last edit: Ashok P. Nadkarni 2012-11-08
Thank you for dealing with this problem!
The code above is only the test case. To give more info: Basically my tcl script starts a simulation tool, waits for it to terminate itself and then works with the result files the tool has written. Therefore the tcl script checks every few seconds if the process is still active.
It's a good question if the problem occurs only while the process is currently being terminated. I tend to say that this is actually the case, but I will check this.