-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUGS: get_lasterrors and set_lasterrors #16
Comments
Thank you for pointing out these issues! It is much appreciated. Issue 1 fixed in be0d4d5 Regarding the VS2019 compiler error, as far as I can tell this is not an issue with VS2017. Therefore, this is duly noted and will be useful if and when it's decided to move to VS2019. |
I can confirm this. I also noted it in the description ("141 builds it just fine"). At the moment, I am trying to make PoC of bad compiler behavior in order to send it to the compiler guys, hoping they will fix it. |
I am also using VS2019 and had run into an initial issue of Winword not starting up on either Windows 7 or Windows 10 with my builds of diff --git a/bson/bson.vcxproj b/bson/bson.vcxproj
index b841018..627d2c9 100644
--- a/bson/bson.vcxproj
+++ b/bson/bson.vcxproj
@@ -40,7 +40,7 @@
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
@@ -48,7 +48,7 @@
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
diff --git a/capemon.vcxproj b/capemon.vcxproj
index 91dcb0c..188ec6e 100644
--- a/capemon.vcxproj
+++ b/capemon.vcxproj
@@ -43,7 +43,7 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
<UseOfMfc>false</UseOfMfc>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
@@ -51,7 +51,7 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>NotSet</CharacterSet>
- <WholeProgramOptimization>true</WholeProgramOptimization>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
<UseOfMfc>false</UseOfMfc>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup> |
Thanks Michael. I made a minimalistic proof-of-concept of the compiler bug and trying to reach Microsoft people. Yes, I did the same observation - as soon as you remove inlining on the (s|g)et_lasterrors, it goes away. It also goes away if you remove the condition at line 372. |
The intrinsic function
__readeflags()
used in get_lasterrors() returns 64-bit value on 64-bit build. It is necessary to changelasterror_t::Eflags
toDWORD_PTR
What is the meaning of the condition at line 372? It causes the problem described below
The code created by conditional
__writeeflags()
at line 372 inset_lasterrors
seems to invoke error in compiler.How to reproduce the compiler error:
New_NtOpenFile
New_NtOpenFile
:check_for_logging_resumption()
functionI experimented a bit. The V142 platform toolset makes functions
get_lasterrors
andset_lasterrors
inline. As consequence, there are "pushfq - pop" constructs (created by__readeflags()
and__writeeflags()
) all over the place. This operation causes RSP to be copied into R11 at the beginning ofcheck_for_logging_resumption
. RBX is stored to stack cell referenced byR11+imm
, but it's restored from different stack cell referenced byRSP+imm
.TLDR: I found that preventing both
get_lasterrors
andset_lasterrors
from being inlined (viavoid declspec (noinline) get_lasterrors(lasterror_t *errors)
will make the bug go away.The text was updated successfully, but these errors were encountered: