ossia / libossia

A modern C++, cross-environment distributed object model for creative coding and interaction scoring
https://ossia.io
GNU Lesser General Public License v3.0
204 stars 33 forks source link

Consistent crash in osc_query_mirror_protocol::get_host_info on windows when querying "oscquery helper" host on a mac on the network #684

Open onar3d opened 3 years ago

onar3d commented 3 years ago

Hi!

This crashes consistently for me, running the latest develop branch as of today.

The libossia hosting software is on windows, the OSCQuery helper, with the default example project file, on a mac on the network. I fetch the zeroconf list, and use the item for the example host.

This works - status is indeed ready.

        auto hostString = queryHostString.toStdString();
        auto protocol = new ossia::oscquery::oscquery_mirror_protocol(hostString, inPortInt);
        m_Device = std::make_unique<ossia::net::generic_device>(std::unique_ptr<ossia::net::protocol_base>(protocol), "Mirror");

        auto fut = m_Device->get_protocol().update_async(m_Device->get_root_node());
        auto status = fut.wait_for(std::chrono::seconds(5));
        if (status == std::future_status::ready)
        {
                parseHostInfo(protocol);
        }

But then in the parseHostInfo call I consistently get the crash.

Stack trace from Visual Studio:

Exception thrown: read access violation. _Right_data was 0xFFFFFFFFFFFFFFE7.

` ossia_x64d.dll!std::string::_Construct_lv_contents(const std::string & _Right) Line 2734 C++ ossia_x64d.dll!std::string::basic_string<char,std::char_traits,std::allocator>(const std::string & _Right) Line 2355 C++

ossia_x64d.dll!std::pair<std::string,bool>::pair<std::string,bool>(const std::pair<std::string,bool> & __that) Line 906 C++ [External Code] ossia_x64d.dll!tsl::detail_hopscotch_hash::hopscotch_hash<std::pair<std::string,bool>,tsl::hopscotch_map<std::string,bool,ossia::string_hash,ossia::string_equal,std::allocator<std::pair<std::string,bool>>,4,0,tsl::hh::power_of_two_growth_policy<2>>::KeySelect,tsl::hopscotch_map<std::string,bool,ossia::string_hash,ossia::string_equal,std::allocator<std::pair<std::string,bool>>,4,0,tsl::hh::power_of_two_growth_policy<2>>::ValueSelect,ossia::string_hash,ossia::string_equal,std::allocator<std::pair<std::string,bool>>,4,0,tsl::hh::power_of_two_growth_policy<2>,std::list<std::pair<std::string,bool>,std::allocator<std::pair<std::string,bool>>>>::hopscotch_hash<std::pair<std::string,bool>,tsl::hopscotch_map<std::string,bool,ossia::string_hash,ossia::string_equal,std::allocator<std::pair<std::string,bool>>,4,0,tsl::hh::power_of_two_growth_policy<2>>::KeySelect,tsl::hopscotch_map<std::string,bool,ossia::string_hash,ossia::string_equal,std::allocator<std::pair<std::string,bool>>,4,0,tsl::hh::power_of_two_growth_policy<2>>::ValueSelect,ossia::string_hash,ossia::string_equal,std::allocator<std::pair<std::string,bool>>,4,0,tsl::hh::power_of_two_growth_policy<2>,std::list<std::pair<std::string,bool>,std::allocator<std::pair<std::string,bool>>>>(const tsl::detail_hopscotch_hash::hopscotch_hash<std::pair<std::string,bool>,tsl::hopscotch_map<std::string,bool,ossia::string_hash,ossia::string_equal,std::allocator<std::pair<std::string,bool>>,4,0,tsl::hh::power_of_two_growth_policy<2>>::KeySelect,tsl::hopscotch_map<std::string,bool,ossia::string_hash,ossia::string_equal,std::allocator<std::pair<std::string,bool>>,4,0,tsl::hh::power_of_two_growth_policy<2>>::ValueSelect,ossia::string_hash,ossia::string_equal,std::allocator<std::pair<std::string,bool>>,4,0,tsl::hh::power_of_two_growth_policy<2>,std::list<std::pair<std::string,bool>,std::allocator<std::pair<std::string,bool>>>> & other) Line 677 C++ [External Code] ossia_x64d.dll!ossia::oscquery::oscquery_mirror_protocol::get_host_info() Line 530 C++ TWO.exe!OSCQueryAddress::parseHostInfo(ossia::oscquery::oscquery_mirror_protocol * protocol) Line 599 C++ TWO.exe!OSCQueryAddress::connectAndQuery() Line 491 C++ TWO.exe!OSCQueryAddress::run() Line 1030 C++ `

This is reproducible using the test project I had already shared for OS X - but adding and using a windows build target, and using the latest libossia if needed of course: https://forum.ossia.io/t/trouble-using-native-macos-static-v1-0-9-on-os-x-for-osc-query-in-c-application/206

onar3d commented 3 years ago

I tried running the OSCQuery Helper on two different computers just in case, the issue persists irrespective of which mac it is on.

jcelerier commented 3 years ago

thanks for the report - we're kinda busy next week as we're having a week-long meeting but I'll do my best to look at it

onar3d commented 3 years ago

I'll check back if I find anything in the meanwhile!

I'm cleaning out all my projects and replacing all produced binary files just in case it's some garbage causing it...

onar3d commented 3 years ago

No, I tried cleaning everything and running it with the 1.2.2 win release, and then clearing again and using .dll and .lib from my own build of the master tip today.

Same crash.

I can't imagine there being a problem in my using the /include folder from the 1.2.2 release in the latter case, when I built my own .lib and dll?

As an aside, is there a script I can run on Windows that gathers those files, making a win release, or is that osx/linux only?

jcelerier commented 3 years ago

Okay, I checked this and I'd be inclined to believe that this is a threading issue : the m_host_info could be written to by the network thread and isn't protected by a mutex. Fixing that, sorry for the delay...