[Bug 46908] New: Support msvcp mtx_init 'mtx_try' flag (0x2) to create a mutex object that supports test and return

wine-bugs at winehq.org wine-bugs at winehq.org
Mon Mar 25 09:49:04 CDT 2019


https://bugs.winehq.org/show_bug.cgi?id=46908

            Bug ID: 46908
           Summary: Support msvcp mtx_init 'mtx_try' flag (0x2) to create
                    a mutex object that supports test and return
           Product: Wine
           Version: 4.4
          Hardware: x86-64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: msvcp
          Assignee: wine-bugs at winehq.org
          Reporter: focht at gmx.net
      Distribution: ---

Hello folks,

some apps cause a significant spam = slowdown due to the following FIXME:

--- snip ---
fixme:msvcp:_Mtx_init_in_situ unknown flags ignored: 2
--- snip ---

You can find various bug reports which include such spam:

https://bugs.winehq.org/show_bug.cgi?id=46800#c3

I've encountered this recently in an even more annoying form with SIMATIC WinCC
V15.1 Runtime services. Although the spam is partially caused by other bugs
(error paths), it completely bogs down the console when a prefix is
bootstrapped (emitted by 'autostart' type service).

--- snip ---
$ du -sh log.txt 
1.4G    log.txt

$ egrep "fixme:.*_Mtx_init_in_situ" log.txt   | wc -l
97512

$ egrep "fixme:.*_Mtx_init_in_situ" log.txt | sort | uniq 
0012:fixme:msvcp:_Mtx_init_in_situ unknown flags ignored: 102
0012:fixme:msvcp:_Mtx_init_in_situ unknown flags ignored: 2
001c:fixme:msvcp:_Mtx_init_in_situ unknown flags ignored: 1
001c:fixme:msvcp:_Mtx_init_in_situ unknown flags ignored: 2
001f:fixme:msvcp:_Mtx_init_in_situ unknown flags ignored: 2
0021:fixme:msvcp:_Mtx_init_in_situ unknown flags ignored: 2
0022:fixme:msvcp:_Mtx_init_in_situ unknown flags ignored: 2
004a:fixme:msvcp:_Mtx_init_in_situ unknown flags ignored: 102
004e:fixme:msvcp:_Mtx_init_in_situ unknown flags ignored: 2
--- snip ---

--- snip ---
001c:Call msvcp140._Cnd_init_in_situ(0025bcc8) ret=1400b97a8
001c:Call ntdll.RtlInitializeConditionVariable(0025bcc8) ret=7f168a0b198f
001c:Ret  ntdll.RtlInitializeConditionVariable() retval=0025bcc8
ret=7f168a0b198f
001c:Ret  msvcp140._Cnd_init_in_situ() retval=00000044 ret=1400b97a8
001c:Call msvcp140._Mtx_init_in_situ(0025bd10,00000002) ret=1400b97b8
001c:fixme:msvcp:_Mtx_init_in_situ unknown flags ignored: 2
001c:Call msvcr120.??0critical_section at Concurrency@@QEAA at XZ(0025bd18)
ret=7f168a0b1629
001c:Ret  msvcr120.??0critical_section at Concurrency@@QEAA at XZ() retval=0025bd18
ret=7f168a0b1629
001c:Ret  msvcp140._Mtx_init_in_situ() retval=0025bd10 ret=1400b97b8 
...
004a:Call msvcp110._Mtx_init(002626c8,00000102) ret=0091104c
004a:Call msvcr110.??2 at YAPEAX_K@Z(00000048) ret=7f88bd859199
004a:Call ntdll.RtlAllocateHeap(00230000,00000000,00000048) ret=7f88c03b15ef
004a:Ret  ntdll.RtlAllocateHeap() retval=00262710 ret=7f88c03b15ef
004a:Ret  msvcr110.??2 at YAPEAX_K@Z() retval=00262710 ret=7f88bd859199
004a:fixme:msvcp:_Mtx_init_in_situ unknown flags ignored: 102
004a:Call msvcr110.??0critical_section at Concurrency@@QEAA at XZ(00262718)
ret=7f88bd85910a
...
--- snip ---

Although this spam can masked/filtered out, it should be considered to
implement the missing mutex types.

Currently Wine only supports C11 'mtx_recursive' mutex type (flags = 0x100).

Wine source:

https://source.winehq.org/git/wine.git/blob/HEAD:/dlls/msvcp90/misc.c#l684

--- snip ---
 684 #define MTX_MULTI_LOCK 0x100
 685 #define MTX_LOCKED 3
 686 typedef struct
 687 {
 688     DWORD flags;
 689     critical_section cs;
 690     DWORD thread_id;
 691     DWORD count;
 692 } *_Mtx_t;
 693 
 694 #if _MSVCP_VER >= 140
 695 typedef _Mtx_t _Mtx_arg_t;
 696 #define MTX_T_FROM_ARG(m)   (m)
 697 #define MTX_T_TO_ARG(m)     (m)
 698 #else
 699 typedef _Mtx_t *_Mtx_arg_t;
 700 #define MTX_T_FROM_ARG(m)   (*(m))
 701 #define MTX_T_TO_ARG(m)     (&(m))
 702 #endif
 703 
 704 void __cdecl _Mtx_init_in_situ(_Mtx_t mtx, int flags)
 705 {
 706     if(flags & ~MTX_MULTI_LOCK)
 707         FIXME("unknown flags ignored: %x\n", flags);
 708 
 709     mtx->flags = flags;
 710     call_func1(critical_section_ctor, &mtx->cs);
 711     mtx->thread_id = -1;
 712     mtx->count = 0;
 713 }
--- snip ---

>From C11 standard (ISO/IEC 9899:2011): 

https://en.cppreference.com/w/c/thread/mtx_init

NOTE: 'mtx_try' is not mentioned here anymore, see
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1521.htm

--- quote ---
mtx_init

C Thread support library

Defined in header <threads.h>

int mtx_init( mtx_t* mutex, int type );
        (since C11)


Creates a new mutex object with type. The object pointed to by mutex is set to
an identifier of the newly created mutex.

type must have one of the following values:

    mtx_plain - a simple, non-recursive mutex is created.
    mtx_timed - a non-recursive mutex, that supports timeout, is created.
    mtx_plain | mtx_recursive - a recursive mutex is created.
    mtx_timed | mtx_recursive - a recursive mutex, that supports timeout, is
created. 

Parameters
mutex     -     pointer to the mutex to initialize
type     -     the type of the mutex
Return value

thrd_success if successful, thrd_error otherwise.
References

    C11 standard (ISO/IEC 9899:2011): 

        7.26.4.2 The mtx_init function (p: 381) 
--- quote ---

ftp://ftp.00f.net/misc/n1548.pdf

--- quote ---
The enumeration constants are

mtx_plain

which is passed to mtx_init to create a mutex object that supports neither 
imeout nor test and return;

mtx_recursive

which is passed to mtx_initto create a mutex object that supports recursive
locking;

mtx_timed

which is passed to mtx_init to create a mutex object that supports timeout;

mtx_try

which is passed to mtx_init to create a mutex object that supports test and
return;
--- quote ---

* mtx_plain = 0x1
* mtx_try = 0x2
* mtx_timed = 0x4
* mtx_recursive = 0x100

$ sha1sum SIMATIC_WinCC_Runtime_Advanced_V15_1.exe
db1f97bb648b62fa1c5d974d7f2bcb6b4a9fd786 
SIMATIC_WinCC_Runtime_Advanced_V15_1.exe

$ du -sh SIMATIC_WinCC_Runtime_Advanced_V15_1.exe
1.3G    SIMATIC_WinCC_Runtime_Advanced_V15_1.exe

$ wine --version
wine-4.4-188-gc988910cae

Regards

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list