Azure / azure-sdk-for-cpp

This repository is for active development of the Azure SDK for C++. For consumers of the SDK we recommend visiting our versioned developer docs at https://azure.github.io/azure-sdk-for-cpp.
MIT License
175 stars 126 forks source link

Can't run example blob due to BlobContainerClient crashing in LogOptions set(const set& _Right) #5855

Open jamwhy opened 1 month ago

jamwhy commented 1 month ago

Describe the bug

Unhandled exception thrown: read access violation. _Right_scary->_Myhead was 0x1.

Exception or Stack Trace

    template <_Strategy _Strat>
    void _Copy(const _Tree& _Right) { // copy or move entire tree from _Right
        const auto _Scary        = _Get_scary();
        const auto _Right_scary  = _Right._Get_scary();
        _Scary->_Myhead->_Parent = _Copy_nodes<_Strat>(_Right_scary->_Myhead->_Parent, _Scary->_Myhead); <---- exception here

Disassembly of the call to the copy above:
pvcl_test.exe!Azure::Core::Http::Policies::LogOptions::LogOptions(void):
00007FF6B3B0BBD0  mov         qword ptr [rsp+8],rcx  
00007FF6B3B0BBD5  push        rdi  
00007FF6B3B0BBD6  sub         rsp,30h  
00007FF6B3B0BBDA  mov         rax,qword ptr [this]  
00007FF6B3B0BBDF  mov         qword ptr [rsp+20h],rax  
00007FF6B3B0BBE4  mov         rdx,qword ptr [__imp_Azure::Core::Http::Policies::_detail::g_defaultAllowedHttpQueryParameters (07FF6B48F9448h)]  
00007FF6B3B0BBEB  mov         rcx,qword ptr [rsp+20h]  
00007FF6B3B0BBF0  call        std::set<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::set<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > (07FF6B39AA80Dh)  

Executing this call from the example:
auto containerClient = BlobContainerClient::CreateFromConnectionString(GetConnectionString(), "sandbox");

azure_test.exe!std::_Tree<std::_Tset_traits<std::string,std::less<std::string>,std::allocator<std::string>,0>>::_Copy<0>(const std::_Tree<std::_Tset_traits<std::string,std::less<std::string>,std::allocator<std::string>,0>> & _Right) Line 1633  C++
    azure_test.exe!std::_Tree<std::_Tset_traits<std::string,std::less<std::string>,std::allocator<std::string>,0>>::_Tree<std::_Tset_traits<std::string,std::less<std::string>,std::allocator<std::string>,0>><std::allocator<std::_Tree_node<std::string,void *>>>(const std::_Tree<std::_Tset_traits<std::string,std::less<std::string>,std::allocator<std::string>,0>> & _Right, std::allocator<std::_Tree_node<std::string,void *>> && _Al) Line 898    C++
    azure_test.exe!std::set<std::string,std::less<std::string>,std::allocator<std::string>>::set<std::string,std::less<std::string>,std::allocator<std::string>>(const std::set<std::string,std::less<std::string>,std::allocator<std::string>> & _Right) Line 87   C++
    azure_test.exe!Azure::Core::Http::Policies::LogOptions::LogOptions()    C++
    azure_test.exe!Azure::Core::_internal::ClientOptions::ClientOptions() Line 56   C++
    [External Code] 

To Reproduce Build and run the example from here: https://github.com/Azure/azure-sdk-for-cpp or here: https://github.com/Azure/azure-sdk-for-cpp/blob/main/sdk/storage/azure-storage-blobs/samples/blob_getting_started.cpp

I tried this with both examples, both produce the same results. The LogOptions have some issue when the ClientOptions() = default; is called creating a BlobContainerClient

Code Snippet auto containerClient = BlobContainerClient::CreateFromConnectionString(GetConnectionString(), "sandbox");

Expected behavior Don't crash

Setup (please complete the following information):

github-actions[bot] commented 1 month ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Jinming-Hu @microzchang @vinjiang.

Jinming-Hu commented 1 month ago

Crashed when constructing the std::set here.

https://github.com/Azure/azure-sdk-for-cpp/blob/20e3bd3ff442f0ce018e9f99542ba22704b1d091/sdk/core/azure-core/inc/azure/core/http/policies/policy.hpp#L149

Is there anything special about the global variable? @RickWinter Can your team take a look?

RickWinter commented 1 month ago

@ahsonkhan can you help out investigating this issue.