Skip to content
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

Fix false positive for string initialization in header with initterm in callstack #63

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/callstack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ UINT CallStack::isCrtStartupFunction( LPCWSTR functionName ) const
|| (wcscmp(functionName, L"_Getctype") == 0)
|| (wcscmp(functionName, L"std::_Facet_Register") == 0)
|| endWith(functionName, len, L">::_Getcat")
// Fix
|| endWith(functionName, len, L"initterm")
) {
return CALLSTACK_STATUS_STARTUPCRT;
}
Expand Down
8 changes: 8 additions & 0 deletions src/tests/static_string_test/static_string.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include <string>

namespace my_string
{
const std::string the_string("foobar");
}
32 changes: 32 additions & 0 deletions src/tests/static_string_test/static_string_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// static_string_test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "vld.h"
#include "static_string.h"

void access_string()
{
// Just do something with the string so it isn't optimized away
std::string copied_string = my_string::the_string;
printf("Copied string %s\n", copied_string.c_str());
}

int main(int argc, char **argv)
{
access_string();

int leaks = static_cast<int>(VLDGetLeaksCount());
if (0 != leaks)
{
printf("!!! FAILED - Leaks detected: %i\n", leaks);
VLDReportLeaks();
}
else
{
printf("PASSED\n");
}


return leaks;
}
343 changes: 343 additions & 0 deletions src/tests/static_string_test/static_string_test.vcxproj

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions src/tests/static_string_test/static_string_test.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="static_string.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="static_string_test.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions src/tests/static_string_test/stdafx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// basics.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
15 changes: 15 additions & 0 deletions src/tests/static_string_test/stdafx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>



// TODO: reference additional headers your program requires here
8 changes: 8 additions & 0 deletions src/tests/static_string_test/targetver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

// Including SDKDDKVer.h defines the highest available Windows platform.

// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.

#include <SDKDDKVer.h>
1,023 changes: 525 additions & 498 deletions vld_vs14.sln

Large diffs are not rendered by default.