[CXX-2707] mongocxx kvp std::string runtime error in visual studio 2019 release build. Created: 06/Jul/23  Updated: 27/Oct/23  Resolved: 31/Jul/23

Status: Closed
Project: C++ Driver
Component/s: API, Build, Release
Affects Version/s: 3.7.2
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Wansang Han [한완상] Assignee: Ezra Chung
Resolution: Gone away Votes: 0
Labels: Bug
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File 제목 없음.png    
Issue Links:
Related
related to CXX-2726 Do not override CMAKE_BUILD_TYPE for ... Closed

 Description   

Summary

I am using mongocxx in windows visual studio 2019.

When i set std::string value in kvp function's first argument, rumtime error occur in release build.

When i set const char array value in kvp function's first argument, it works without runtime error.

How can i use std::string in kvp function's first argument without runtime error?

Environment

mongoc : 1.23.5

mongocxx : 3.7.2

OS : Windows 10 64-bit

compiler : Visual studio 2019, version : 16.11.27

How to Reproduce

// Test is GTest

TEST(MongoTest, AppendTest)

{     std::string data\{ "abc" }

;
    make_document(kvp(data, "123"));
}

Additional Background

 



 Comments   
Comment by PM Bot [ 31/Jul/23 ]

There hasn't been any recent activity on this ticket, so we're resolving it. Thanks for reaching out! Please feel free to reopen this ticket if you're still experiencing the issue, and add a comment if you're able to provide more information.

Comment by PM Bot [ 19/Jul/23 ]

Hi wshan@kabaminc.com! CXX-2707 is awaiting your response.

If this is still an issue for you, please open Jira to review the latest status and provide your feedback. Thanks!

Comment by Ezra Chung [ 11/Jul/23 ]

Hello, wshan@kabaminc.com. Using a std::string as the key in a key-value pair is a feature that has been supported and tested for a very long time.

We suspect this error may instead be caused by the use of incompatible build configurations for the bsoncxx library vs. the test application. The build configuration for a Windows application must be consistent with the build configuration of all the libraries being linked against. To compile and link the test application using the Release configuration, it must link against a bsoncxx library which was also built using the Release configuration. Specifically, the stack trace suggests this may be due to bsoncxx being built with a non-zero _ITERATOR_DEBUG_LEVEL (debug) while the test application is being built with _ITERATOR_DEBUG_LEVEL set to 0 (release). If you want to build the test application in Release mode, ensure the bsoncxx library being linked against was also built in Release mode.

Comment by PM Bot [ 06/Jul/23 ]

Hi wshan@kabaminc.com, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Wed Feb 07 22:06:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.