http://bugs.winehq.org/show_bug.cgi?id=20230
Summary: GetThreadTimes() and the Actual and Pseudo Current Thread Handles Product: Wine Version: 1.1.30 Platform: PC URL: http://rh-software.com OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: ntdll AssignedTo: wine-bugs@winehq.org ReportedBy: ray@pobox.co.uk
Some time ago I had an issue with SIV being unable to read the thread CPU time usage when using GetThreadTimes(). I tracked down to the following and then did a work-a-round.
The "Current Thread" effectively has 2 current thread handles, these are the actual thread handle and the ~0 pseudo handle as returned by GetCurrentThread(). When a call is made to GetThreadTimes() this calls NtQueryInformationThread( ThreadTimes ) which contains the test "if (handle == GetCurrentThread())". As a result of this when GetThreadTimes() is called with the actual thread handle no data is returned.
\WINE-1.1.30\dlls\ntdll\thread.c(1011): if (handle == GetCurrentThread())
I suspect the code should be changed to allow both the pseudo and actual thread handles to be used as a minimum, better still would, when possible, be to implement this function for any thread.
While searching the source I also noticed:
NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class, LPCVOID data, ULONG length ) { NTSTATUS status; switch(class) { case ThreadZeroTlsCell: if (handle == GetCurrentThread())
And suspect that code would benefit from a similar fix.
http://bugs.winehq.org/show_bug.cgi?id=20230
--- Comment #1 from ray@pobox.co.uk 2011-04-16 09:36:37 CDT --- Created an attachment (id=34147) --> (http://bugs.winehq.org/attachment.cgi?id=34147) Patch to fix GetThreadTimes() to work for all threads
The patch works by reading from /proc/<pid>/task/<tid>/stat. If this in not possible it will report the fix messages as before.
Given that SystemProcessorPerformanceInformation uses /proc/stat I expect this is OK.
Do I also need to send the patch to wine patches?
http://bugs.winehq.org/show_bug.cgi?id=20230
ray@pobox.co.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |ray@pobox.co.uk
http://bugs.winehq.org/show_bug.cgi?id=20230
--- Comment #2 from ray@pobox.co.uk 2011-04-16 09:43:37 CDT --- Created an attachment (id=34148) --> (http://bugs.winehq.org/attachment.cgi?id=34148) Test Version of SIV32X.exe
To test the patch run SIV32X.exe and go Menu->Edit->STC Info.
http://bugs.winehq.org/show_bug.cgi?id=20230
--- Comment #3 from Austin English austinenglish@gmail.com 2011-04-17 20:36:40 CDT --- (In reply to comment #1)
Do I also need to send the patch to wine patches?
Yes.
http://bugs.winehq.org/show_bug.cgi?id=20230
ray@rh-software.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #34147|0 |1 is obsolete| |
--- Comment #4 from ray@rh-software.com 2011-04-19 03:51:47 CDT --- Created an attachment (id=34196) --> (http://bugs.winehq.org/attachment.cgi?id=34196) Fix GetThreadTimes for all threads
2nd attempt
http://bugs.winehq.org/show_bug.cgi?id=20230
ray@rh-software.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download
http://bugs.winehq.org/show_bug.cgi?id=20230
ray@rh-software.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #34196|0 |1 is obsolete| |
--- Comment #5 from ray@rh-software.com 2011-04-19 14:25:50 CDT --- Created an attachment (id=34229) --> (http://bugs.winehq.org/attachment.cgi?id=34229) Fix GetThreadTimes for all threads
http://bugs.winehq.org/show_bug.cgi?id=20230
Ken Sharp kennybobs@o2.co.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- Alias|GetThreadTimes() |
http://bugs.winehq.org/show_bug.cgi?id=20230
--- Comment #6 from Austin English austinenglish@gmail.com 2013-09-11 19:45:56 CDT --- (In reply to comment #2)
Created attachment 34148 [details] Test Version of SIV32X.exe
To test the patch run SIV32X.exe and go Menu->Edit->STC Info.
I don't see the Menu option anywhere..anyway, that code hasn't changed in years, so still present.
https://bugs.winehq.org/show_bug.cgi?id=20230
Sebastian Lackner sebastian@fds-team.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |sebastian@fds-team.de
--- Comment #7 from Sebastian Lackner sebastian@fds-team.de --- I have added the patch to the staging tree: https://github.com/wine-compholio/wine-staging/tree/master/patches/ntdll-Thr...
Please note that the implementation in comment #5 has a major flaw, when the filename (second argument in the file) contains spaces. This should be fixed in my updated version. Moreover I decided to always use /proc on Linux, otherwise there is no proper way to get the kernel time for the current thread.
https://bugs.winehq.org/show_bug.cgi?id=20230
Michael Müller michael@fds-team.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |STAGED CC| |michael@fds-team.de Ever confirmed|0 |1 Staged patchset| |https://github.com/wine-com | |pholio/wine-staging/tree/ma | |ster/patches/ntdll-ThreadTi | |me
https://bugs.winehq.org/show_bug.cgi?id=20230
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch
https://bugs.winehq.org/show_bug.cgi?id=20230
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |focht@gmx.net Summary|GetThreadTimes() and the |SIV (System Information |Actual and Pseudo Current |Viewer) needs |Thread Handles |GetThreadTimes() to return | |correct values for all | |threads Staged patchset|https://github.com/wine-com |https://github.com/wine-sta |pholio/wine-staging/tree/ma |ging/wine-staging/tree/mast |ster/patches/ntdll-ThreadTi |er/patches/ntdll-ThreadTime |me |
--- Comment #8 from Anastasius Focht focht@gmx.net --- Hello folks,
updating some fields.
NOTE: The referenced Wine-Staging patchset https://github.com/wine-staging/wine-staging/tree/master/patches/ntdll-Threa... mixes different problems. Hence other, unrelated patches from this patchset might be linked from other tickets.
$ wine --version wine-3.4
Regards
https://bugs.winehq.org/show_bug.cgi?id=20230
tokktokk fdsfgs@krutt.org changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |fdsfgs@krutt.org
https://bugs.winehq.org/show_bug.cgi?id=20230
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|SIV (System Information |Multiple system information |Viewer) needs |tools and debuggers need |GetThreadTimes() to return |GetThreadTimes() to return |correct values for all |correct values for all |threads |threads (SIV System | |Information Viewer, Ollydbg | |1.x/2.x, x64dbg)
--- Comment #9 from Anastasius Focht focht@gmx.net --- Hello folks,
Zeb made a new attempt to get patches in:
https://www.winehq.org/pipermail/wine-devel/2020-June/167306.html
--- quote --- The only applications associated with this patch, and the others in the series, are essentially system process monitors. Accordingly, it's not really providing anything useful over host utilities such as ps(1).
This patch helps System Information Viewer, and the other two in the series help Process Hacker. --- quote ---
Actually the first patch also helps multiple debuggers. Ollydbg v1.x/2.x and x64dbg have a 'Threads' view which includes display of user/kernel CPU time of all the debuggee threads in real-time which is useful in certain situations.
Refining summary to reference these tools as well.
Regards
https://bugs.winehq.org/show_bug.cgi?id=20230
Zebediah Figura z.figura12@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |z.figura12@gmail.com Resolution|--- |FIXED Status|STAGED |RESOLVED Fixed by SHA1| |847b93c7400f82225057e8b7193 | |8eb8ccd5d23be
--- Comment #10 from Zebediah Figura z.figura12@gmail.com --- Fixed by https://source.winehq.org/git/wine.git/commitdiff/847b93c7400f82225057e8b71938eb8ccd5d23be.
https://bugs.winehq.org/show_bug.cgi?id=20230
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #11 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 5.12.
https://bugs.winehq.org/show_bug.cgi?id=20230
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- URL|http://rh-software.com |https://web.archive.org/web | |/20101102153355/http://olly | |dbg.de/odbg200.zip