Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Globals destruction order may cause deadlock with ~Trace #13

@nunoplopes

Description

@nunoplopes

If Python exits and there's something in the trace, Torchy will hold pointers to PyTorch tensors in Trace::inputs.
The call trace for ~Trace looks like:

#0  futex_abstimed_wait_cancelable()
#1  __pthread_cond_wait_common()
#2  __pthread_cond_timedwait()
#3  PyCOND_TIMEDWAIT()
#4  take_gil()
#5  PyEval_AcquireThread()
#6  pybind11::gil_scoped_acquire::gil_scoped_acquire()
#7  std::_Function_handler<void (void*), torch::utils::tensor_from_numpy(_object*, bool)::{lambda(void*)#1}>::_M_invoke(std::_Any_data const&, void*&&) ()
#8  c10::deleteInefficientStdFunctionContext(void*)
#9  c10::StorageImpl::release_resources()
#10 c10::TensorImpl::release_resources()
#11 c10::intrusive_ptr<c10::intrusive_ptr_target, c10::UndefinedTensorImpl>::reset_()
#12 c10::intrusive_ptr<c10::intrusive_ptr_target, c10::UndefinedTensorImpl>::~intrusive_ptr()
#13 c10::IValue::destroy()
#14 c10::IValue::~IValue()
#15 std::_Destroy<c10::IValue>()
#16 std::_Destroy_aux<false>::__destroy<c10::IValue*>()
#17 std::_Destroy<c10::IValue*>()
#18 std::_Destroy<c10::IValue*, c10::IValue>()
#19 std::vector<c10::IValue, std::allocator<c10::IValue> >::~vector()
#20 Trace::~Trace()
#21 __run_exit_handlers()
#22 __GI_exit()
#23 __libc_start_main()
#24 _start () at python_1635226063427/work/Parser/parser.c:325

~Trace must be called before PyTorch is destroyed. We must register a callback somehow? Maybe in our PYBIND11_MODULE def?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions