Skip to content

Commit 7299312

Browse files
committed
Disable support for pthread_keyt destructors
They are too expensive due to extensive shared-variable use.
1 parent dcd8227 commit 7299312

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/ansi-c/library/pthread_lib.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,15 @@ inline void pthread_exit(void *value_ptr)
301301
{
302302
__CPROVER_HIDE:;
303303
if(value_ptr!=0) (void)*(char*)value_ptr;
304+
#if 0
304305
for(unsigned long i = 0; i < __CPROVER_next_thread_key; ++i)
305306
{
306307
const void *key = __CPROVER_thread_keys[i];
307308
__CPROVER_thread_keys[i] = 0;
308309
if(__CPROVER_thread_key_dtors[i] && key)
309310
__CPROVER_thread_key_dtors[i](key);
310311
}
312+
#endif
311313
__CPROVER_threads_exited[__CPROVER_thread_id]=1;
312314
__CPROVER_assume(0);
313315
}
@@ -541,16 +543,20 @@ extern __CPROVER_thread_local unsigned long __CPROVER_next_thread_key;
541543

542544
inline void __spawned_thread(
543545
unsigned long this_thread_id,
546+
#if 0
544547
void (**thread_key_dtors)(void *),
548+
#endif
545549
unsigned long next_thread_key,
546550
void *(*start_routine)(void *),
547551
void *arg)
548552
{
549553
__CPROVER_HIDE:;
550554
__CPROVER_thread_id = this_thread_id;
551555
__CPROVER_next_thread_key = next_thread_key;
556+
#if 0
552557
for(unsigned long i = 0; i < __CPROVER_next_thread_key; ++i)
553558
__CPROVER_thread_key_dtors[i] = thread_key_dtors[i];
559+
#endif
554560
#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
555561
// Clear all locked mutexes; locking must happen in same thread.
556562
__CPROVER_clear_must(0, "mutex-locked");
@@ -566,13 +572,15 @@ __CPROVER_HIDE:;
566572
"RRcumul",
567573
"RWcumul",
568574
"WRcumul");
575+
#if 0
569576
for(unsigned long i = 0; i < __CPROVER_next_thread_key; ++i)
570577
{
571578
const void *key = __CPROVER_thread_keys[i];
572579
__CPROVER_thread_keys[i] = 0;
573580
if(__CPROVER_thread_key_dtors[i] && key)
574581
__CPROVER_thread_key_dtors[i](key);
575582
}
583+
#endif
576584
__CPROVER_threads_exited[this_thread_id] = 1;
577585
}
578586

@@ -598,11 +606,19 @@ inline int pthread_create(
598606
if(attr) (void)*attr;
599607

600608
unsigned long next_thread_key = __CPROVER_next_thread_key;
609+
#if 0
601610
void (**thread_key_dtors)(void *) = __CPROVER_thread_key_dtors;
611+
#endif
602612

603613
__CPROVER_ASYNC_1:
604614
__spawned_thread(
605-
this_thread_id, thread_key_dtors, next_thread_key, start_routine, arg);
615+
this_thread_id,
616+
#if 0
617+
thread_key_dtors,
618+
#endif
619+
next_thread_key,
620+
start_routine,
621+
arg);
606622

607623
return 0;
608624
}
@@ -895,7 +911,11 @@ inline int pthread_key_create(pthread_key_t *key, void (*destructor)(void *))
895911
{
896912
__CPROVER_HIDE:;
897913
__CPROVER_thread_keys[__CPROVER_next_thread_key] = 0;
914+
#if 0
898915
__CPROVER_thread_key_dtors[__CPROVER_next_thread_key] = destructor;
916+
#else
917+
__CPROVER_precondition(destructor == 0, "destructors are not yet supported");
918+
#endif
899919
*key = __CPROVER_next_thread_key++;
900920
return 0;
901921
}

0 commit comments

Comments
 (0)