Ignore:
Timestamp:
Feb 7, 2026, 1:40:26 PM (26 hours ago)
Author:
Matthew Au-Yeung <mw2auyeu@…>
Branches:
stuck-waitfor-destruct
Parents:
c7d106a
git-author:
Matthew Au-Yeung <mw2auyeu@…> (02/07/26 13:40:05)
git-committer:
Matthew Au-Yeung <mw2auyeu@…> (02/07/26 13:40:26)
Message:

Add a generated hash to fix stuck waitfor comparing static inline mutex destructors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/invoke.h

    rc7d106a ra9ce782  
    159159                // last function that acquired monitors
    160160                fptr_t func;
     161
     162                // hash-based function identity for cross-TU matching
     163                func_id_t func_id;
    161164        };
    162165
     
    288291                        (this.size){0};
    289292                        (this.func){NULL};
    290                 }
    291 
    292                 static inline void ?{}(__monitor_group_t & this, struct monitor$ ** data, __lock_size_t size, fptr_t func) {
     293                        (this.func_id){0};
     294                }
     295
     296                static inline void ?{}(__monitor_group_t & this, struct monitor$ ** data, __lock_size_t size, fptr_t func, func_id_t func_id) {
    293297                        (this.data){data};
    294298                        (this.size){size};
    295299                        (this.func){func};
     300                        (this.func_id){func_id};
    296301                }
    297302
     
    299304                        if( (lhs.data != 0) != (rhs.data != 0) ) return false;
    300305                        if( lhs.size != rhs.size ) return false;
    301                         if( lhs.func != rhs.func ) return false;
     306                        // Use hash-based comparison when both sides have a valid func_id,
     307                        // otherwise fall back to function pointer comparison (for library code
     308                        // like join() that cannot compute the hash at compile time).
     309                        if( lhs.func_id != 0 && rhs.func_id != 0 ) {
     310                                if( lhs.func_id != rhs.func_id ) return false;
     311                        } else {
     312                                if( lhs.func != rhs.func ) return false;
     313                        }
    302314
    303315                        // Check that all the monitors match
     
    314326                        lhs.size = rhs.size;
    315327                        lhs.func = rhs.func;
     328                        lhs.func_id = rhs.func_id;
    316329                }
    317330        }
Note: See TracChangeset for help on using the changeset viewer.