File: select.c

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (117 lines) | stat: -rw-r--r-- 4,350 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* COVERAGE: select pselect6 pselect7 */
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/select.h>
#include <signal.h>
#include <sys/syscall.h>

int main()
{
  int fd;
  struct timespec tim = {0, 200000000};
  sigset_t sigs;
  fd_set rfds;
  struct timeval tv = {0, 117};

  sigemptyset(&sigs);
  sigaddset(&sigs,SIGUSR2);

  select(1, &rfds, NULL, NULL, &tv);
  //staptest// [[[[select (1, XXXX, 0x[0]+, 0x[0]+, \[0.000117\])!!!!pselect6 (1, XXXX, 0x[0]+, 0x[0]+, \[0.000117[0]+\], 0x0)]]]]

  tv.tv_sec = 0;
  tv.tv_usec = 113;

  select(1, NULL, NULL, NULL, &tv);
  //staptest// [[[[select (1, 0x[0]+, 0x[0]+, 0x[0]+, \[0.000113\])!!!!pselect6 (1, 0x[0]+, 0x[0]+, 0x[0]+, \[0.000113[0]+\], 0x0)]]]]

  tv.tv_sec = 0;
  tv.tv_usec = 120;
  select(-1, &rfds, NULL, NULL, &tv);
  //staptest// [[[[select (-1, XXXX, 0x[0]+, 0x[0]+, \[0.000120\]!!!!pselect6 (-1, XXXX, 0x[0]+, 0x[0]+, \[0.000120[0]+\], 0x0]]]]) = -NNNN (EINVAL)

  tv.tv_sec = 0;
  tv.tv_usec = 121;
  select(1, (fd_set *)-1, NULL, NULL, &tv);
#ifdef __s390__
  //staptest// select (1, 0x[7]?[f]+, 0x[0]+, 0x[0]+, \[0.000121\]) = [[[[0!!!!-NNNN (EFAULT)]]]]
#else
  //staptest// [[[[select (1, 0x[f]+, 0x[0]+, 0x[0]+, \[0.000121\]!!!!pselect6 (1, 0x[f]+, 0x[0]+, 0x[0]+, \[0.000121[0]+\], 0x0]]]]) = [[[[0!!!!-NNNN (EFAULT)]]]]
#endif

  tv.tv_sec = 0;
  tv.tv_usec = 122;
  select(1, &rfds, (fd_set *)-1, NULL, &tv);
#ifdef __s390__
  //staptest// select (1, XXXX, 0x[7]?[f]+, 0x[0]+, \[0.000122\]) = [[[[0!!!!-NNNN (EFAULT)]]]]
#else
  //staptest// [[[[select (1, XXXX, 0x[f]+, 0x[0]+, \[0.000122\]!!!!pselect6 (1, XXXX, 0x[f]+, 0x[0]+, \[0.000122[0]+\], 0x0]]]]) = [[[[0!!!!-NNNN (EFAULT)]]]]
#endif

  tv.tv_sec = 0;
  tv.tv_usec = 123;
  select(1, &rfds, NULL, (fd_set *)-1, &tv);
#ifdef __s390__
  //staptest// select (1, XXXX, 0x[0]+, 0x[7]?[f]+, \[0.000123\]) = [[[[0!!!!-NNNN (EFAULT)]]]]
#else
  //staptest// [[[[select (1, XXXX, 0x[0]+, 0x[f]+, \[0.000123\]!!!!pselect6 (1, XXXX, 0x[0]+, 0x[f]+, \[0.000123[0]+\], 0x0]]]]) = [[[[0!!!!-NNNN (EFAULT)]]]]
#endif

// The following subtest SEGVs (the part using the glibc wrapper) with modern glibc having commit
// "9d7c5cc38e linux: Normalize and return timeout on select (BZ #27651)" Since it's trying to
// dereference the invalid timeout pointer (-1) like this:
// __time64_t s = timeout != NULL ? timeout->tv_sec : 0;
// Disable whole the subtest with modern glibc.
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) && __GLIBC__ <= 2 && __GLIBC_MINOR__ <= 33
#if defined(__arm__) || defined(__aarch64__)
  syscall(SYS_pselect6, 1, &rfds, NULL, NULL, (struct timeval *)-1);
#else
  select(1, &rfds, NULL, NULL, (struct timeval *)-1);
#endif
#ifdef __s390__
  //staptest// select (1, XXXX, 0x[0]+, 0x[0]+, 0x[7]?[f]+) = -NNNN (EFAULT)
#else
  //staptest// [[[[select (1, XXXX, 0x[0]+, 0x[0]+, 0x[f]+!!!!pselect6 (1, XXXX, 0x[0]+, 0x[0]+, 0x[f]+, 0x0]]]]) = -NNNN (EFAULT)
#endif
#endif

#if defined(SYS_pselect6) || defined(SYS_pselect7)
  pselect( 1, &rfds, NULL, NULL, &tim, &sigs);
  //staptest//pselect[67] (1, XXXX, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) = NNNN

  pselect( 0, NULL, NULL, NULL, &tim, &sigs);
  //staptest// pselect[67] (0, 0x[0]+, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) = NNNN

  pselect(-1, NULL, NULL, NULL, &tim, &sigs);
  //staptest//pselect[67] (-1, 0x[0]+, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) = -NNNN

  pselect(1, (fd_set *)-1, NULL, NULL, &tim, &sigs);
#ifdef __s390__
  //staptest//pselect[67] (1, 0x[7]?[f]+, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) = NNNN
#else
  //staptest//pselect[67] (1, 0x[f]+, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) = NNNN
#endif

  pselect(1, &rfds, (fd_set *)-1, NULL, &tim, &sigs);
#ifdef __s390__
  //staptest//pselect[67] (1, XXXX, 0x[7]?[f]+, 0x[0]+, \[0.200000000\], XXXX) = NNNN
#else
  //staptest//pselect[67] (1, XXXX, 0x[f]+, 0x[0]+, \[0.200000000\], XXXX) = NNNN
#endif

  pselect(1, &rfds, NULL, (fd_set *)-1, &tim, &sigs);
#ifdef __s390__
  //staptest//pselect[67] (1, XXXX, 0x[0]+, 0x[7]?[f]+, \[0.200000000\], XXXX) = NNNN
#else
  //staptest//pselect[67] (1, XXXX, 0x[0]+, 0x[f]+, \[0.200000000\], XXXX) = NNNN
#endif

  // This causes the exe to get a SIGSEGV...
  //pselect(1, &rfds, NULL, NULL, (struct timespec *)-1, &sigs);

  // glibc is "fixing" this one...
  //pselect(1, &rfds, NULL, NULL, &tim, (sigset_t *)-1);
#endif

  return 0;
}