Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET
Roslyn
提交
d58f06dd
R
Roslyn
项目概览
dotNET
/
Roslyn
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d58f06dd
编写于
6月 01, 2017
作者:
T
Tomáš Matoušek
提交者:
GitHub
6月 01, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix race condition in EnC implementation that might cause VS crash (#19910)
Fix race condition in EnC implementation
上级
d9a45089
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
29 addition
and
44 deletion
+29
-44
src/VisualStudio/Core/Def/Implementation/EditAndContinue/Interop/NativeMethods.cs
...f/Implementation/EditAndContinue/Interop/NativeMethods.cs
+3
-2
src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs
...ementation/EditAndContinue/VsENCRebuildableProjectImpl.cs
+26
-42
未找到文件。
src/VisualStudio/Core/Def/Implementation/EditAndContinue/Interop/NativeMethods.cs
浏览文件 @
d58f06dd
...
...
@@ -20,9 +20,10 @@ public static int GetStreamForObject(object pUnk, out IntPtr stream)
return
CoMarshalInterThreadInterfaceInStream
(
ref
s_IID_IUnknown
,
pUnk
,
out
stream
);
}
public
static
int
GetObjectForStream
(
IntPtr
stream
,
out
object
pUnk
)
public
static
object
GetObjectAndRelease
(
IntPtr
stream
)
{
return
CoGetInterfaceAndReleaseStream
(
stream
,
ref
s_IID_IUnknown
,
out
pUnk
);
Marshal
.
ThrowExceptionForHR
(
CoGetInterfaceAndReleaseStream
(
stream
,
ref
s_IID_IUnknown
,
out
object
pUnk
));
return
pUnk
;
}
}
}
src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs
浏览文件 @
d58f06dd
...
...
@@ -90,9 +90,7 @@ internal sealed class VsENCRebuildableProjectImpl
/// </summary>
private
ModuleMetadata
_metadata
;
private
ISymUnmanagedReader3
_pdbReader
;
private
IntPtr
_pdbReaderObjAsStream
;
private
Lazy
<
ISymUnmanagedReader3
>
_pdbReader
;
#
endregion
...
...
@@ -348,16 +346,14 @@ public int StopDebuggingPE()
_activeStatementIds
=
null
;
_projectBeingEmitted
=
null
;
Debug
.
Assert
(
_pdbReaderObjAsStream
==
IntPtr
.
Zero
||
_pdbReader
==
null
);
if
(
_pdbReader
!=
null
)
var
pdbReader
=
Interlocked
.
Exchange
(
ref
_pdbReader
,
null
);
if
(
pdbReader
?.
IsValueCreated
==
true
)
{
if
(
Marshal
.
IsComObject
(
_pdbReader
))
var
symReader
=
pdbReader
.
Value
;
if
(
Marshal
.
IsComObject
(
symReader
))
{
Marshal
.
ReleaseComObject
(
_pdb
Reader
);
Marshal
.
ReleaseComObject
(
sym
Reader
);
}
_pdbReader
=
null
;
}
// The HResult is ignored by the debugger.
...
...
@@ -990,11 +986,10 @@ public unsafe int BuildForEnc(object pUpdatePE)
var
updater
=
(
IDebugUpdateInMemoryPE2
)
pUpdatePE
;
if
(
_committedBaseline
==
null
)
{
var
hr
=
MarshalPdbReader
(
updater
,
out
_pdbReaderObjAsStream
,
out
_pdbReader
);
if
(
hr
!=
VSConstants
.
S_OK
)
{
return
hr
;
}
var
previousPdbReader
=
Interlocked
.
Exchange
(
ref
_pdbReader
,
MarshalPdbReader
(
updater
));
// PDB reader should have been nulled out when debugging stopped:
Contract
.
ThrowIfFalse
(
previousPdbReader
==
null
);
_committedBaseline
=
EmitBaseline
.
CreateInitialBaseline
(
_metadata
,
GetBaselineEncDebugInfo
);
}
...
...
@@ -1114,32 +1109,21 @@ private Deltas EmitProjectDelta()
private
EditAndContinueMethodDebugInformation
GetBaselineEncDebugInfo
(
MethodDefinitionHandle
methodHandle
)
{
Debug
.
Assert
(
Thread
.
CurrentThread
.
GetApartmentState
()
==
ApartmentState
.
MTA
);
InitializePdbReader
();
return
GetEditAndContinueMethodDebugInfo
(
_pdbReader
,
methodHandle
);
return
GetEditAndContinueMethodDebugInfo
(
_pdbReader
.
Value
,
methodHandle
);
}
private
void
InitializePdbReader
()
// Unmarshal the symbol reader (being marshalled cross thread from STA -> MTA).
private
static
ISymUnmanagedReader3
UnmarshalSymReader
(
IntPtr
stream
)
{
Debug
.
Assert
(
Thread
.
CurrentThread
.
GetApartmentState
()
==
ApartmentState
.
MTA
);
if
(
_pdbReader
==
null
)
try
{
// Unmarshal the symbol reader (being marshalled cross thread from STA -> MTA).
Debug
.
Assert
(
_pdbReaderObjAsStream
!=
IntPtr
.
Zero
);
var
exception
=
Marshal
.
GetExceptionForHR
(
NativeMethods
.
GetObjectForStream
(
_pdbReaderObjAsStream
,
out
object
pdbReaderObjMta
));
if
(
exception
!=
null
)
return
(
ISymUnmanagedReader3
)
NativeMethods
.
GetObjectAndRelease
(
stream
);
}
catch
(
Exception
exception
)
when
(
FatalError
.
ReportWithoutCrash
(
exception
))
{
// likely a bug in the compiler/debugger
FatalError
.
ReportWithoutCrash
(
exception
);
throw
new
InvalidDataException
(
exception
.
Message
,
exception
);
}
_pdbReaderObjAsStream
=
IntPtr
.
Zero
;
_pdbReader
=
(
ISymUnmanagedReader3
)
pdbReaderObjMta
;
}
}
private
static
EditAndContinueMethodDebugInformation
GetEditAndContinueMethodDebugInfo
(
ISymUnmanagedReader3
symReader
,
MethodDefinitionHandle
methodHandle
)
...
...
@@ -1309,7 +1293,7 @@ public int GetCurrentExceptionSpanPosition(uint exceptionRegionId, VsTextSpan[]
}
}
private
static
int
MarshalPdbReader
(
IDebugUpdateInMemoryPE2
updater
,
out
IntPtr
pdbReaderPointer
,
out
ISymUnmanagedReader3
managedSymRead
er
)
private
static
Lazy
<
ISymUnmanagedReader3
>
MarshalPdbReader
(
IDebugUpdateInMemoryPE2
updat
er
)
{
// ISymUnmanagedReader can only be accessed from an MTA thread, however, we need
// fetch the IUnknown instance (call IENCSymbolReaderProvider.GetSymbolReader) here
...
...
@@ -1332,16 +1316,16 @@ private static int MarshalPdbReader(IDebugUpdateInMemoryPE2 updater, out IntPtr
symbolReaderProvider
.
GetSymbolReader
(
out
object
pdbReaderObjSta
);
if
(
Marshal
.
IsComObject
(
pdbReaderObjSta
))
{
int
hr
=
NativeMethods
.
GetStreamForObject
(
pdbReaderObjSta
,
out
pdbReaderPointer
);
int
hr
=
NativeMethods
.
GetStreamForObject
(
pdbReaderObjSta
,
out
IntPtr
stream
);
Marshal
.
ReleaseComObject
(
pdbReaderObjSta
);
managedSymReader
=
null
;
return
hr
;
Marshal
.
ThrowExceptionForHR
(
hr
);
return
new
Lazy
<
ISymUnmanagedReader3
>(()
=>
UnmarshalSymReader
(
stream
));
}
else
{
pdbReaderPointer
=
IntPtr
.
Zero
;
managedSymReader
=
(
ISymUnmanagedReader3
)
pdbReaderObjSta
;
return
0
;
var
managedSymReader
=
(
ISymUnmanagedReader3
)
pdbReaderObjSta
;
return
new
Lazy
<
ISymUnmanagedReader3
>(()
=>
managedSymReader
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录