ECP-VeloC / AXL

Asynchronous Transfer Library
MIT License
2 stars 8 forks source link

bbapi transfers save pointer to tdef, which can lead to a crash on resume #81

Open adammoody opened 3 years ago

adammoody commented 3 years ago

During AXL_Create, we are saving a pointer to a transfer definition in the kvtree, which is then saved to the state file.

https://github.com/ECP-VeloC/AXL/blob/a799cd9b7a406a80173ecb2bf3a32000f432f8ce/src/axl_async_bbapi.c#L276

On resume, this pointer is extracted here, which can lead to a crash on StartTransfer:

https://github.com/ECP-VeloC/AXL/blob/a799cd9b7a406a80173ecb2bf3a32000f432f8ce/src/axl_async_bbapi.c#L362

We need to check any/all pointers that are saved in the kvtree to make sure those values aren't referenced after a resume.

tonyhutter commented 3 years ago

Thanks for catching this. It's definitely a bug, but not as bad as it may seem (and it only affects BBAPI). The two most common BBAPI cases will work fine and should not trigger the bug:

  1. AXL_Add() + AXL_Dispatch() + app crashes + app restarts and transfer is still going + AXL_Resume() + AXL_Wait()
  2. AXL_Add() + AXL_Dispatch() + app crashes + transfer completes in background + app restarts + AXL_Resume() + AXL_Wait()

That said, I can see this being an issue if you do:

AXL_Add() + app crashes + app restarts + AXL_Resume() + AXL_Wait().