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

Crash on ableton::Link constructor when compiled to bundle, and called from Unity #121

Open
MeijisIrlnd opened this issue Oct 4, 2022 · 2 comments

Comments

@MeijisIrlnd
Copy link

MeijisIrlnd commented Oct 4, 2022

Hi all,
My use case here is pretty niche, I'm using the Juce framework for our audio stuff, and Unity for the frontend, and have been trying to integrate link into this setup.
It works fine on Windows, but on mac, Link's constructor causes a crash. I tried stripping the bundle down to its bare minimum for testing purposes, so the exported function is:

{
    __attribute__((visibility("default"))) void test()
    {
        ableton::Link* test = new ableton::Link{120};
    }
}

I'm defining LINK_PLATFORM_MACOSX=1, and the relevant part of the stack trace is:

#0  0x0000019b8697ec in asio::detail::conditionally_enabled_mutex::scoped_lock::scoped_lock(asio::detail::conditionally_enabled_mutex&)
#1  0x0000019b86949d in asio::detail::conditionally_enabled_mutex::scoped_lock::scoped_lock(asio::detail::conditionally_enabled_mutex&)
#2  0x0000019b87b1f1 in asio::detail::scheduler::init_task()
#3  0x0000019b87b1c9 in asio::detail::kqueue_reactor::init_task()
#4  0x0000019b891dfb in asio::detail::deadline_timer_service<asio::detail::chrono_time_traits<std::__1::chrono::system_clock, asio::wait_traits<std::__1::chrono::system_clock> > >::deadline_timer_service(asio::execution_context&)
#5  0x0000019b891d6d in asio::detail::deadline_timer_service<asio::detail::chrono_time_traits<std::__1::chrono::system_clock, asio::wait_traits<std::__1::chrono::system_clock> > >::deadline_timer_service(asio::execution_context&)
#6  0x0000019b891d20 in asio::execution_context::service* asio::detail::service_registry::create<asio::detail::deadline_timer_service<asio::detail::chrono_time_traits<std::__1::chrono::system_clock, asio::wait_traits<std::__1::chrono::system_clock> > >, asio::io_context>(void*)
#7  0x0000019b8677ea in asio::detail::service_registry::do_use_service(asio::execution_context::service::key const&, asio::execution_context::service* (*)(void*), void*)
#8  0x0000019b891cae in asio::detail::deadline_timer_service<asio::detail::chrono_time_traits<std::__1::chrono::system_clock, asio::wait_traits<std::__1::chrono::system_clock> > >& asio::detail::service_registry::use_service<asio::detail::deadline_timer_service<asio::detail::chrono_time_traits<std::__1::chrono::system_clock, asio::wait_traits<std::__1::chrono::system_clock> > > >(asio::io_context&)
#9  0x0000019b891bcc in asio::detail::deadline_timer_service<asio::detail::chrono_time_traits<std::__1::chrono::system_clock, asio::wait_traits<std::__1::chrono::system_clock> > >& asio::use_service<asio::detail::deadline_timer_service<asio::detail::chrono_time_traits<std::__1::chrono::system_clock, asio::wait_traits<std::__1::chrono::system_clock> > > >(asio::io_context&)
#10 0x0000019b891af7 in asio::detail::io_object_impl<asio::detail::deadline_timer_service<asio::detail::chrono_time_traits<std::__1::chrono::system_clock, asio::wait_traits<std::__1::chrono::system_clock> > >, asio::any_io_executor>::io_object_impl<asio::io_context>(int, int, asio::io_context&)
#11 0x0000019b891ac9 in asio::detail::io_object_impl<asio::detail::deadline_timer_service<asio::detail::chrono_time_traits<std::__1::chrono::system_clock, asio::wait_traits<std::__1::chrono::system_clock> > >, asio::any_io_executor>::io_object_impl<asio::io_context>(int, int, asio::io_context&)
#12 0x0000019b891a94 in asio::basic_waitable_timer<std::__1::chrono::system_clock, asio::wait_traits<std::__1::chrono::system_clock>, asio::any_io_executor>::basic_waitable_timer<asio::io_context>(asio::io_context&, asio::constraint<is_convertible<asio::io_context&, asio::execution_context&>::value, int>::type)
#13 0x0000019b8919d3 in asio::basic_waitable_timer<std::__1::chrono::system_clock, asio::wait_traits<std::__1::chrono::system_clock>, asio::any_io_executor>::basic_waitable_timer<asio::io_context>(asio::io_context&, asio::constraint<is_convertible<asio::io_context&, asio::execution_context&>::value, int>::type)
#14 0x0000019b891942 in ableton::platforms::asio::AsioTimer::AsioTimer(asio::io_context&)
#15 0x0000019b8918ed in ableton::platforms::asio::AsioTimer::AsioTimer(asio::io_context&)
#16 0x0000019b8917c0 in ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory>::makeTimer() const
#17 0x0000019b8f370b in ableton::link::Sessions<ableton::link::Peers<ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory>&, std::__1::reference_wrapper<ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::SessionPeerCounter>, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::SessionTimelineCallback, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::SessionStartStopStateCallback>&, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::MeasurePeer, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::JoinSessionCallback, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory>&, ableton::platforms::darwin::Clock>::Sessions(ableton::link::Session, ableton::util::Injected<ableton::link::Peers<ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory>&, std::__1::reference_wrapper<ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::SessionPeerCounter>, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::SessionTimelineCallback, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::SessionStartStopStateCallback>&>, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::MeasurePeer, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::JoinSessionCallback, ableton::util::Injected<ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory>&>, ableton::platforms::darwin::Clock)
#18 0x0000019b864747 in ableton::link::Sessions<ableton::link::Peers<ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory>&, std::__1::reference_wrapper<ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::SessionPeerCounter>, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::SessionTimelineCallback, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::SessionStartStopStateCallback>&, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::MeasurePeer, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::JoinSessionCallback, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory>&, ableton::platforms::darwin::Clock>::Sessions(ableton::link::Session, ableton::util::Injected<ableton::link::Peers<ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory>&, std::__1::reference_wrapper<ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::SessionPeerCounter>, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::SessionTimelineCallback, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::SessionStartStopStateCallback>&>, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::MeasurePeer, ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::JoinSessionCallback, ableton::util::Injected<ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory>&>, ableton::platforms::darwin::Clock)
#19 0x0000019b863d8e in ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::Controller(ableton::link::Tempo, std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock)
#20 0x0000019b859729 in ableton::link::Controller<std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock, ableton::platforms::stl::Random, ableton::platforms::asio::Context<ableton::platforms::posix::ScanIpIfAddrs, ableton::util::NullLog, ableton::platforms::darwin::ThreadFactory> >::Controller(ableton::link::Tempo, std::__1::function<void (unsigned long)>, std::__1::function<void (ableton::link::Tempo)>, std::__1::function<void (bool)>, ableton::platforms::darwin::Clock)
#21 0x0000019b85945d in ableton::BasicLink<ableton::platforms::darwin::Clock>::BasicLink(double)
#22 0x0000019b8592bf in ableton::Link::Link(double)
#23 0x0000019b85894f in ableton::Link::Link(double)

After looking through the call stack for a while, it looks like Scheduler is null.
Wondering if anyone has any insight on how to proceed with this, I know there's a Unity version of Link, but for integration with our system it makes more sense to use the c++ version, I wonder if there are some defines its missing or something?

@fgo-ableton
Copy link
Collaborator

fgo-ableton commented Oct 11, 2022

Sorry, I don't any insight on Unity/Juce. As folks seem to be using Link with both frameworks I wouldn't expect any general issue.
Is is maybe possible you are accessing a ableton::Link* when it is not properly initialized?

@MeijisIrlnd
Copy link
Author

Not really I don't think, the function I posted is how I was doing the setup for testing purposes, unless there are any library functions aside from the constructor I have to call beforehand (which there don't seem to be), the problem seemed to be something to do with Asio's timer, know thats a little vague haven't looked at it in a while!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants