8
8
#define _GNU_SOURCE
9
9
#endif
10
10
11
+ #include <errno.h>
11
12
#include <pthread.h>
12
13
#include "libcgo.h"
13
14
@@ -20,16 +21,21 @@ x_cgo_getstackbound(uintptr bounds[2])
20
21
21
22
// Needed before pthread_getattr_np, too, since before glibc 2.32
22
23
// it did not call pthread_attr_init in all cases (see #65625).
23
- pthread_attr_init (& attr );
24
+ if (pthread_attr_init (& attr ) != 0 )
25
+ fatalf ("pthread_attr_init failed: %d" , errno );
24
26
#if defined(__GLIBC__ ) || defined(__BIONIC__ ) || (defined(__sun ) && !defined(__illumos__ ))
25
27
// pthread_getattr_np is a GNU extension supported in glibc.
26
28
// Solaris is not glibc but does support pthread_getattr_np
27
29
// (and the fallback doesn't work...). Illumos does not.
28
- pthread_getattr_np (pthread_self (), & attr ); // GNU extension
29
- pthread_attr_getstack (& attr , & addr , & size ); // low address
30
+ if (pthread_getattr_np (pthread_self (), & attr ) != 0 ) // GNU extension
31
+ fatalf ("pthread_getattr_np failed: %d" , errno );
32
+ if (pthread_attr_getstack (& attr , & addr , & size ) != 0 ) // low address
33
+ fatalf ("pthread_attr_getstack failed: %d" , errno );
30
34
#elif defined(__illumos__ )
31
- pthread_attr_get_np (pthread_self (), & attr );
32
- pthread_attr_getstack (& attr , & addr , & size ); // low address
35
+ if (pthread_attr_get_np (pthread_self (), & attr ) != 0 ) // Illumos extension
36
+ fatalf ("pthread_attr_get_np failed: %d" , errno );
37
+ if (pthread_attr_getstack (& attr , & addr , & size ) != 0 ) // low address
38
+ fatalf ("pthread_attr_getstack failed: %d" , errno );
33
39
#else
34
40
// We don't know how to get the current stacks, leave it as
35
41
// 0 and the caller will use an estimate based on the current
0 commit comments