On 05/28/2012 12:10 AM, Ivica Ico Bukvic wrote:
Never mind. Just had a look at pd_bind/unbind code. This makes me wonder what if all bindings/unbindings were handled as lists? Would this potentially break anything (other than having to modify bind/unbind mechanism)? Does anything else depend on 2-member list vs. 1-member pointer in terms of bindings? I suspect there would be some cpu impact on having it implemented this way, but not that much.
Actually, please try attached patch. It fixes all such crashes for me on pd-l2ork. Basically it has a static variable set within m_pd.c that is turned on only when one of bindlist_<var>() functions is called in which case any potential memory deallocation calls within pd_unbind are deferred until all members of bindlist->b_list have been served with data. After that bindlist_cleanup does its thing based on which members have e_who pointing to NULL and that's that. In the event a call arrives outside those bindlist_<var>() functions, it immediately deallocates stuff as is currently the case with pd vanilla and extended.
Potential caveat: if one somehow invokes an event outside regular execution of the code and it somehow arrives exactly during that narrow span of time when the static var is enabled, its memory deallocation will be ignored. I am however unsure if this is theoretically even possible since my understanding is that the graph is never being executed out-of-sync. Please correct me if I am wrong.
Cheers!