File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,6 +151,8 @@ task:
151151 chown -R rootless.rootless /home/rootless
152152 # set PATH
153153 echo 'export PATH=/usr/local/go/bin:/usr/local/bin:$PATH' >> /root/.bashrc
154+ # set CGO_CFLAGS
155+ echo 'export CGO_CFLAGS="-DDONT_USE_PR_GET_TID_ADDRESS=1"' >> /root/.bashrc
154156 # Setup ssh localhost for terminal emulation (script -e did not work)
155157 ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -N ""
156158 cat /root/.ssh/id_ed25519.pub >> /root/.ssh/authorized_keys
Original file line number Diff line number Diff line change 2929 race : ["-race", ""]
3030 criu : ["", "criu-dev"]
3131 dmz : ["", "runc_nodmz"]
32+ tidscan : ["", "-DDONT_USE_PR_GET_TID_ADDRESS=1"]
3233 exclude :
3334 # Disable most of criu-dev jobs, as they are expensive
3435 # (need to compile criu) and don't add much value/coverage.
@@ -151,6 +152,7 @@ jobs:
151152 - name : build
152153 env :
153154 EXTRA_BUILDTAGS : ${{ matrix.dmz }}
155+ CGO_CFLAGS : ${{ matrix.tidscan }}
154156 run : sudo -E PATH="$PATH" make EXTRA_FLAGS="${{ matrix.race }}" all
155157
156158 - name : install bats
@@ -162,6 +164,7 @@ jobs:
162164 if : matrix.rootless != 'rootless'
163165 env :
164166 EXTRA_BUILDTAGS : ${{ matrix.dmz }}
167+ CGO_CFLAGS : ${{ matrix.tidscan }}
165168 run : sudo -E PATH="$PATH" -- make TESTFLAGS="${{ matrix.race }}" localunittest
166169
167170 - name : add rootless user
Original file line number Diff line number Diff line change @@ -327,6 +327,9 @@ pid_t gettid(void)
327327# define RUNC_TID_KLUDGE 0
328328#endif
329329#if RUNC_TID_KLUDGE
330+ # if !defined(DONT_USE_PR_GET_TID_ADDRESS )
331+ # define DONT_USE_PR_GET_TID_ADDRESS 0
332+ # endif
330333# define TID_OFFSET_SCAN_MAX 1024
331334static int tid_offset = 0 ;
332335
@@ -391,15 +394,18 @@ static pid_t *find_tls_tid_address(void)
391394 .tid = gettid (),
392395 };
393396
397+ # if !DONT_USE_PR_GET_TID_ADDRESS
394398 if (!prctl (PR_GET_TID_ADDRESS , & tid_addr ))
395399 /*
396400 * Make sure the address actually contains the current TID. musl uses a
397401 * different pointer with CLONE_CHILD_CLEARTID, so PR_GET_TID_ADDRESS
398402 * succeeding doesn't mean the address is the one we want.
399403 */
400404 if (tid_addr && * tid_addr == main_tid .tid ) {
401- goto got_tid_addr ;
405+ return tid_addr ;
402406 }
407+ # endif
408+ write_log (DEBUG , "let's try using tid scan to find out the tid address in struct thread" );
403409
404410 /*
405411 * If we cannot use PR_GET_TID_ADDRESS to get &PTHREAD_SELF->tid, we
@@ -439,7 +445,6 @@ static pid_t *find_tls_tid_address(void)
439445 tid_addr = (pid_t * ) (main_tid .handle + tid_offset );
440446 }
441447
442- got_tid_addr :
443448 return tid_addr ;
444449}
445450#endif /* RUNC_TID_KLUDGE */
You can’t perform that action at this time.
0 commit comments