Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
fe0f8a15
Commit
fe0f8a15
authored
Apr 30, 2019
by
Nikolay Sivov
Committed by
Alexandre Julliard
Apr 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Initialize critical section debug info with correct pointer value.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
10bbe111
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
21 deletions
+41
-21
sync.c
dlls/kernel32/sync.c
+2
-1
sync.c
dlls/kernel32/tests/sync.c
+13
-1
critsection.c
dlls/ntdll/critsection.c
+26
-18
rtl.c
dlls/ntdll/tests/rtl.c
+0
-1
No files found.
dlls/kernel32/sync.c
View file @
fe0f8a15
...
...
@@ -402,7 +402,8 @@ void WINAPI MakeCriticalSectionGlobal( CRITICAL_SECTION *crit )
HANDLE
sem
=
crit
->
LockSemaphore
;
if
(
!
sem
)
NtCreateSemaphore
(
&
sem
,
SEMAPHORE_ALL_ACCESS
,
NULL
,
0
,
1
);
crit
->
LockSemaphore
=
ConvertToGlobalHandle
(
sem
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
crit
->
DebugInfo
);
if
(
crit
->
DebugInfo
!=
(
void
*
)(
ULONG_PTR
)
-
1
)
RtlFreeHeap
(
GetProcessHeap
(),
0
,
crit
->
DebugInfo
);
crit
->
DebugInfo
=
NULL
;
}
...
...
dlls/kernel32/tests/sync.c
View file @
fe0f8a15
...
...
@@ -2648,6 +2648,7 @@ static void test_crit_section(void)
InitializeCriticalSection
(
&
cs
);
ok
(
cs
.
DebugInfo
!=
NULL
,
"Unexpected debug info pointer %p.
\n
"
,
cs
.
DebugInfo
);
DeleteCriticalSection
(
&
cs
);
ok
(
cs
.
DebugInfo
==
NULL
,
"Unexpected debug info pointer %p.
\n
"
,
cs
.
DebugInfo
);
if
(
!
pInitializeCriticalSectionEx
)
{
...
...
@@ -2658,9 +2659,20 @@ static void test_crit_section(void)
memset
(
&
cs
,
0
,
sizeof
(
cs
));
ret
=
pInitializeCriticalSectionEx
(
&
cs
,
0
,
CRITICAL_SECTION_NO_DEBUG_INFO
);
ok
(
ret
,
"Failed to initialize critical section.
\n
"
);
todo_wine
ok
(
cs
.
DebugInfo
==
(
void
*
)(
ULONG_PTR
)
-
1
,
"Unexpected debug info pointer %p.
\n
"
,
cs
.
DebugInfo
);
ret
=
TryEnterCriticalSection
(
&
cs
);
ok
(
ret
,
"Failed to enter critical section.
\n
"
);
LeaveCriticalSection
(
&
cs
);
cs
.
DebugInfo
=
NULL
;
ret
=
TryEnterCriticalSection
(
&
cs
);
ok
(
ret
,
"Failed to enter critical section.
\n
"
);
LeaveCriticalSection
(
&
cs
);
DeleteCriticalSection
(
&
cs
);
ok
(
cs
.
DebugInfo
==
NULL
,
"Unexpected debug info pointer %p.
\n
"
,
cs
.
DebugInfo
);
}
START_TEST
(
sync
)
...
...
dlls/ntdll/critsection.c
View file @
fe0f8a15
...
...
@@ -59,6 +59,13 @@ static inline void small_pause(void)
#endif
}
static
void
*
no_debug_info_marker
=
(
void
*
)(
ULONG_PTR
)
-
1
;
static
BOOL
crit_section_has_debuginfo
(
const
RTL_CRITICAL_SECTION
*
crit
)
{
return
crit
->
DebugInfo
!=
NULL
&&
crit
->
DebugInfo
!=
no_debug_info_marker
;
}
#ifdef __linux__
static
int
wait_op
=
128
;
/*FUTEX_WAIT|FUTEX_PRIVATE_FLAG*/
...
...
@@ -226,7 +233,7 @@ static inline NTSTATUS wait_semaphore( RTL_CRITICAL_SECTION *crit, int timeout )
NTSTATUS
ret
;
/* debug info is cleared by MakeCriticalSectionGlobal */
if
(
!
crit
->
DebugInfo
||
((
ret
=
fast_wait
(
crit
,
timeout
))
==
STATUS_NOT_IMPLEMENTED
))
if
(
!
crit
_section_has_debuginfo
(
crit
)
||
((
ret
=
fast_wait
(
crit
,
timeout
))
==
STATUS_NOT_IMPLEMENTED
))
{
HANDLE
sem
=
get_semaphore
(
crit
);
LARGE_INTEGER
time
;
...
...
@@ -321,20 +328,21 @@ NTSTATUS WINAPI RtlInitializeCriticalSectionEx( RTL_CRITICAL_SECTION *crit, ULON
* so (e.g.) MakeCriticalSectionGlobal() doesn't free it using HeapFree().
*/
if
(
flags
&
RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO
)
crit
->
DebugInfo
=
NULL
;
crit
->
DebugInfo
=
no_debug_info_marker
;
else
crit
->
DebugInfo
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
sizeof
(
RTL_CRITICAL_SECTION_DEBUG
));
if
(
crit
->
DebugInfo
)
{
crit
->
DebugInfo
->
Type
=
0
;
crit
->
DebugInfo
->
CreatorBackTraceIndex
=
0
;
crit
->
DebugInfo
->
CriticalSection
=
crit
;
crit
->
DebugInfo
->
ProcessLocksList
.
Blink
=
&
(
crit
->
DebugInfo
->
ProcessLocksList
);
crit
->
DebugInfo
->
ProcessLocksList
.
Flink
=
&
(
crit
->
DebugInfo
->
ProcessLocksList
);
crit
->
DebugInfo
->
EntryCount
=
0
;
crit
->
DebugInfo
->
ContentionCount
=
0
;
memset
(
crit
->
DebugInfo
->
Spare
,
0
,
sizeof
(
crit
->
DebugInfo
->
Spare
)
);
crit
->
DebugInfo
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
sizeof
(
RTL_CRITICAL_SECTION_DEBUG
));
if
(
crit
->
DebugInfo
)
{
crit
->
DebugInfo
->
Type
=
0
;
crit
->
DebugInfo
->
CreatorBackTraceIndex
=
0
;
crit
->
DebugInfo
->
CriticalSection
=
crit
;
crit
->
DebugInfo
->
ProcessLocksList
.
Blink
=
&
(
crit
->
DebugInfo
->
ProcessLocksList
);
crit
->
DebugInfo
->
ProcessLocksList
.
Flink
=
&
(
crit
->
DebugInfo
->
ProcessLocksList
);
crit
->
DebugInfo
->
EntryCount
=
0
;
crit
->
DebugInfo
->
ContentionCount
=
0
;
memset
(
crit
->
DebugInfo
->
Spare
,
0
,
sizeof
(
crit
->
DebugInfo
->
Spare
)
);
}
}
crit
->
LockCount
=
-
1
;
crit
->
RecursionCount
=
0
;
...
...
@@ -396,7 +404,7 @@ NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit )
crit
->
LockCount
=
-
1
;
crit
->
RecursionCount
=
0
;
crit
->
OwningThread
=
0
;
if
(
crit
->
DebugInfo
)
if
(
crit
_section_has_debuginfo
(
crit
)
)
{
/* only free the ones we made in here */
if
(
!
crit
->
DebugInfo
->
Spare
[
0
])
...
...
@@ -454,7 +462,7 @@ NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit )
if
(
status
==
STATUS_TIMEOUT
)
{
const
char
*
name
=
NULL
;
if
(
crit
->
DebugInfo
)
name
=
(
char
*
)
crit
->
DebugInfo
->
Spare
[
0
];
if
(
crit
_section_has_debuginfo
(
crit
)
)
name
=
(
char
*
)
crit
->
DebugInfo
->
Spare
[
0
];
if
(
!
name
)
name
=
"?"
;
ERR
(
"section %p %s wait timed out in thread %04x, blocked by %04x, retrying (60 sec)
\n
"
,
crit
,
debugstr_a
(
name
),
GetCurrentThreadId
(),
HandleToULong
(
crit
->
OwningThread
)
);
...
...
@@ -472,7 +480,7 @@ NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit )
if
(
status
==
STATUS_WAIT_0
)
break
;
/* Throw exception only for Wine internal locks */
if
(
(
!
crit
->
DebugInfo
)
||
(
!
crit
->
DebugInfo
->
Spare
[
0
])
)
continue
;
if
(
!
crit_section_has_debuginfo
(
crit
)
||
!
crit
->
DebugInfo
->
Spare
[
0
]
)
continue
;
/* only throw deadlock exception if configured timeout is reached */
if
(
timeout
>
0
)
continue
;
...
...
@@ -485,7 +493,7 @@ NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit )
rec
.
ExceptionInformation
[
0
]
=
(
ULONG_PTR
)
crit
;
RtlRaiseException
(
&
rec
);
}
if
(
crit
->
DebugInfo
)
crit
->
DebugInfo
->
ContentionCount
++
;
if
(
crit
_section_has_debuginfo
(
crit
)
)
crit
->
DebugInfo
->
ContentionCount
++
;
return
STATUS_SUCCESS
;
}
...
...
@@ -518,7 +526,7 @@ NTSTATUS WINAPI RtlpUnWaitCriticalSection( RTL_CRITICAL_SECTION *crit )
NTSTATUS
ret
;
/* debug info is cleared by MakeCriticalSectionGlobal */
if
(
!
crit
->
DebugInfo
||
((
ret
=
fast_wake
(
crit
))
==
STATUS_NOT_IMPLEMENTED
))
if
(
!
crit
_section_has_debuginfo
(
crit
)
||
((
ret
=
fast_wake
(
crit
))
==
STATUS_NOT_IMPLEMENTED
))
{
HANDLE
sem
=
get_semaphore
(
crit
);
ret
=
NtReleaseSemaphore
(
sem
,
1
,
NULL
);
...
...
dlls/ntdll/tests/rtl.c
View file @
fe0f8a15
...
...
@@ -3152,7 +3152,6 @@ static void test_RtlInitializeCriticalSectionEx(void)
memset
(
&
cs
,
0x11
,
sizeof
(
cs
));
pRtlInitializeCriticalSectionEx
(
&
cs
,
0
,
RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO
);
todo_wine
ok
(
cs
.
DebugInfo
==
no_debug
,
"expected DebugInfo == ~0, got %p
\n
"
,
cs
.
DebugInfo
);
ok
(
cs
.
LockCount
==
-
1
,
"expected LockCount == -1, got %d
\n
"
,
cs
.
LockCount
);
ok
(
cs
.
RecursionCount
==
0
,
"expected RecursionCount == 0, got %d
\n
"
,
cs
.
RecursionCount
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment