| 1 |
// Copyright 2024 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package main |
| 6 |
|
| 7 |
// Test case for issue 66427. |
| 8 |
// Running under TSAN, this fails with "signal handler |
| 9 |
// spoils errno". |
| 10 |
|
| 11 |
/* |
| 12 |
#include <pthread.h> |
| 13 |
#include <signal.h> |
| 14 |
#include <stdlib.h> |
| 15 |
|
| 16 |
void go_callback(); |
| 17 |
|
| 18 |
static void *thr(void *arg) { |
| 19 |
int i; |
| 20 |
for (i = 0; i < 10; i++) |
| 21 |
go_callback(); |
| 22 |
return 0; |
| 23 |
} |
| 24 |
|
| 25 |
static void *sendthr(void *arg) { |
| 26 |
pthread_t th = *(pthread_t*)arg; |
| 27 |
while (1) { |
| 28 |
int r = pthread_kill(th, SIGWINCH); |
| 29 |
if (r < 0) |
| 30 |
break; |
| 31 |
} |
| 32 |
return 0; |
| 33 |
} |
| 34 |
|
| 35 |
static void foo() { |
| 36 |
pthread_t *th = malloc(sizeof(pthread_t)); |
| 37 |
pthread_t th2; |
| 38 |
pthread_create(th, 0, thr, 0); |
| 39 |
pthread_create(&th2, 0, sendthr, th); |
| 40 |
pthread_join(*th, 0); |
| 41 |
} |
| 42 |
*/ |
| 43 |
import "C" |
| 44 |
|
| 45 |
import ( |
| 46 |
"time" |
| 47 |
) |
| 48 |
|
| 49 |
//export go_callback |
| 50 |
func go_callback() {} |
| 51 |
|
| 52 |
func main() { |
| 53 |
go func() { |
| 54 |
for { |
| 55 |
C.foo() |
| 56 |
} |
| 57 |
}() |
| 58 |
|
| 59 |
time.Sleep(1000 * time.Millisecond) |
| 60 |
} |