Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Handle free()/destruction failure in containers dtors #474

Open
igchor opened this issue Oct 4, 2019 · 1 comment
Open

Handle free()/destruction failure in containers dtors #474

igchor opened this issue Oct 4, 2019 · 1 comment
Assignees
Labels
Priority: 3 medium Type: Bug Something isn't working Type: Feature New feature or request

Comments

@igchor
Copy link
Contributor

igchor commented Oct 4, 2019

One solution is to call free_data() in delete_persistent method. This will allow to propagate exception and not abort application (if throwed inside destructor). All containers should implement this method.

Another solution is to to use pmdk add_buffer feature to reserve space for free(). The problem is with non-trivial types because we need to call destructors for those. (For trivial types we can skip destruction).

@igchor igchor changed the title Call free_data() in delete_persistent method Handle free() failure in containers Oct 30, 2019
@igchor igchor changed the title Handle free() failure in containers Handle free()/destruction failure in containers Oct 30, 2019
@igchor igchor changed the title Handle free()/destruction failure in containers Handle free()/destruction failure in containers dtors Dec 23, 2019
@igchor igchor self-assigned this Jan 23, 2020
@igchor
Copy link
Contributor Author

igchor commented Jan 23, 2020

The main problem is that exception can be thrown inside of a destructor (because of tx abort). If a destructor is called from within a transaction (always true for delete_peristent) we could just catch any exception and ignore it:

~dtor()
{
   if (pmemobj_tx_stage() == TX_STAGE_WORK) {
     try {
        delete_persistent<>();
     } catch (...) {
       if (pmemobj_tx_stage() == TX_STAGE_ABORT) {} // ignore, outer transaction will see the state and also throw an exception
       else pmemobj_tx_abort();
     }
  } else {
    transaction::run([]{ delete_persistent<>();}); // XXX: should this still cause abort?
  }
}

All this code could be exposed as some generic API.

Some things to keep in mind:

@lukaszstolarczuk lukaszstolarczuk added Type: Bug Something isn't working Type: Feature New feature or request labels Jul 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Priority: 3 medium Type: Bug Something isn't working Type: Feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants