Ignore:
Timestamp:
Nov 14, 2023, 12:18:04 PM (12 months ago)
Author:
caparson <caparson@…>
Branches:
master
Children:
df8ba61a
Parents:
c46c999
Message:

Fixed non-local ehm memory leak that occurs when a coroutine is deleted while suspended in a catchresume handler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/coroutine.cfa

    rc46c999 rcce0807  
    318318void defaultResumeAtHandler( exception_t * except ) {
    319319    __cfaehm_allocate_exception( except );
    320     free( except );
    321320    __cfaehm_begin_unwind( (void(*)(exception_t *))defaultTerminationHandler );
    322321}
     322
     323struct ehm_cleanup {
     324        exception_t * ex;
     325};
     326
     327void ^?{}( ehm_cleanup & this ) { free( this.ex ); }
    323328
    324329bool poll( coroutine$ * cor ) libcfa_public {
     
    330335    // otherwise loop and throwResume all pending exceptions
    331336    while ( nl_ex != 0p ){
    332         exception_t * ex = nl_ex->the_exception;
     337                ehm_cleanup ex_holder{ nl_ex->the_exception };
    333338        free( nl_ex );
    334         __cfaehm_throw_resume( ex, defaultResumeAtHandler );
     339        __cfaehm_throw_resume( ex_holder.ex , defaultResumeAtHandler );
    335340       
    336         // only reached if resumption handled. other dealloc handled in defaultResumeAtHandler
    337         free( ex );
    338341        nl_ex = pop_ehm_head( cor );
    339342    }
Note: See TracChangeset for help on using the changeset viewer.