Skip to content

Commit

Permalink
Workaround MSVC asan bug + Fix failing Csharp CI job
Browse files Browse the repository at this point in the history
  • Loading branch information
byronxu99 committed Aug 25, 2022
1 parent 0de180b commit a6dcbe8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ if(VW_USE_ASAN)
if(MSVC)
add_compile_options(/fsanitize=address /GS- /wd5072)
add_link_options(/InferASanLibs /incremental:no /debug)
# Workaround for MSVC ASan issue here: https://developercommunity.visualstudio.com/t/VS2022---Address-sanitizer-on-x86-Debug-/10116361
add_compile_definitions(_DISABLE_STRING_ANNOTATION)
else()
add_compile_options(-fsanitize=address -fno-omit-frame-pointer -g3)
add_link_options(-fsanitize=address -fno-omit-frame-pointer -g3)
Expand Down Expand Up @@ -348,4 +350,4 @@ set(CPACK_PACKAGE_CONTACT "https://github.com/VowpalWabbit/vowpal_wabbit")
# Generates a package dependency list in the deb control file
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS On)

include(CPack)
include(CPack)
9 changes: 6 additions & 3 deletions cs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@ ELSEIF (vw_BUILD_NET_FRAMEWORK)
# Explicitly set the `PlatformTarget` for C# projects, since AnyCPU can result in
# System.BadImageFormatException throws, when trying to load C++/CLI assemblies.
IF(CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
SET(CMAKE_CSharp_FLAGS "/platform:x64")
SET(CMAKE_CSharp_FLAGS "${CMAKE_CSharp_FLAGS} /platform:x64")
ELSEIF(CMAKE_GENERATOR_PLATFORM STREQUAL "Win32")
SET(CMAKE_CSharp_FLAGS "/platform:x86")
SET(CMAKE_CSharp_FLAGS "${CMAKE_CSharp_FLAGS} /platform:x86")
ELSE()
MESSAGE(WARNING "Generator platform is set to '${CMAKE_GENERATOR_PLATFORM}', which is not supported by managed projects. Defaulting to 'AnyCPU'...")
SET(CMAKE_CSharp_FLAGS "/platform:AnyCPU")
SET(CMAKE_CSharp_FLAGS "${CMAKE_CSharp_FLAGS} /platform:AnyCPU")
ENDIF()

# Needed for Github CodeQL scanning
SET(CMAKE_CSharp_FLAGS "${CMAKE_CSharp_FLAGS} /p:UseSharedCompilation=false")

# StrongName signing for VW assemblies - stage the keyfile, and set its location
configure_file(vw_key.snk vw_key.snk COPYONLY)
set(vw_DOTNET_SIGNING_KEY ${CMAKE_CURRENT_BINARY_DIR}/vw_key.snk)
Expand Down
9 changes: 5 additions & 4 deletions vowpalwabbit/core/src/reductions/metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "vw/core/setup_base.h"
#include "vw/io/logger.h"

#define RAPIDJSON_HAS_STDSTRING 1
#include <rapidjson/filewritestream.h>
#include <rapidjson/writer.h>

Expand Down Expand Up @@ -68,23 +69,23 @@ struct json_metrics_writer : VW::metric_sink_visitor
~json_metrics_writer() override { _writer.EndObject(); }
void int_metric(const std::string& key, uint64_t value) override
{
_writer.Key(key.c_str());
_writer.Key(key);
_writer.Uint64(value);
}
void float_metric(const std::string& key, float value) override
{
_writer.Key(key.c_str());
_writer.Key(key);
_writer.Double(static_cast<double>(value));
}
void string_metric(const std::string& key, const std::string& value) override
{
_writer.Key(key.c_str());
_writer.Key(key);

_writer.String(value.c_str());
}
void bool_metric(const std::string& key, bool value) override
{
_writer.Key(key.c_str());
_writer.Key(key);
_writer.Bool(value);
}

Expand Down

0 comments on commit a6dcbe8

Please sign in to comment.