GithubHelp home page GithubHelp logo

Comments (4)

karya0 avatar karya0 commented on June 28, 2024 1

Thanks for the diagnosis, @JainTwinkle. I just looked and threadlist certainly has a couple of discrepancies around pid handling. I'll create a PR to clean it up.

from dmtcp.

JainTwinkle avatar JainTwinkle commented on June 28, 2024

Information from a GDB session:

(gdb) bt
#0  TLSInfo_GetTidOffset () at tls.cpp:248
#1  0x00007ffff7ecd149 in TLSInfo_GetPidOffset () at tls.cpp:300
#2  0x00007ffff7ecd234 in TLSInfo_VerifyPidTid (pid=8518, tid=8518) at tls.cpp:604
#3  0x00007ffff7ed2e68 in dmtcp::ThreadList::init () at threadlist.cpp:179
#4  0x00007ffff7ebe956 in dmtcp_initialize_entry_point () at dmtcpworker.cpp:293
#5  0x00007ffff7dea9c3 in call_init (env=0x7fffffffdd08, argv=0x7fffffffdcf8, argc=1, l=<optimized out>) at dl-init.c:82
#6  _dl_init (main_map=0x7ffff7ffe150, argc=1, argv=0x7fffffffdcf8, env=0x7fffffffdd08) at dl-init.c:131
#7  0x00007ffff7ddc17a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#8  0x0000000000000001 in ?? ()
#9  0x00007fffffffdfd9 in ?? ()
#10 0x0000000000000000 in ?? ()
(gdb) l
243          * 'struct pthread' is zeroed out before adding tid and pid.
244          * pthread_desc below is defined as 'struct pthread' in glibc:nptl/descr.h
245          */
246         tmp = memsubarray((char *)pthread_desc, (char *)&tid_pid, sizeof(tid_pid));
247
248         if (tmp == NULL && glibcMajorVersion() == 2 && glibcMinorVersion() >= 24) {
249           // starting with glibc-2.25 (including 2.24.90 on Fedora), the pid field
250           // is deprecated and set to zero.
251           tid_pid.pid = 0;
252           tmp = memsubarray((char*)pthread_desc, (char *)&tid_pid, sizeof(tid_pid));
(gdb) l
253         }
254
255         if (tmp == NULL) {
256           JWARNING(false) (tid_pid.tid)
257             .Text("Couldn't find offsets of tid/pid in thread_area.\n"
258                   "  Now relying on the value determined using the\n"
259                   "  glibc version with which DMTCP was compiled.");
260           return STATIC_TLS_TID_OFFSET();
261
262           // mtcp_abort();
(gdb) p tmp
$3 = 0x0
(gdb) p glibcMinorVersion()
$6 = 17
(gdb) p glibcMajorVersion()
$7 = 2

from dmtcp.

JainTwinkle avatar JainTwinkle commented on June 28, 2024

Further debugging shows that pthread_desc(array) and tid_pid(subarray) do not match in memsubarray function:

(gdb) l 319
314       // Assume subarray length is at least sizeof(int) and < 2048.
315       JASSERT(len >= sizeof(int));
316       for (i_ptr = array; i_ptr < array + 2048; i_ptr++) {
317         if (*(int *)i_ptr == word1) {
318           for (j = 0; j < len; j++) {
319             if (i_ptr[j] != subarray[j]) {
320               break;
321             }
322           }
323           if (j == len) {
(gdb) p j
$23 = 4
(gdb) p i_ptr[j]
$19 = 70 'F'
(gdb) p subarray[j]
$20 = 64 '@'
(gdb) x/8c subarray
0x7fffffffd698: 70 'F'  33 '!'  0 '\000'        0 '\000'        64 '@'  -100 '\234'     0 '\000'        0 '\000'
(gdb) x/8c i_ptr
0x7ffff7e4aa50: 70 'F'  33 '!'  0 '\000'        0 '\000'        70 'F'  33 '!'  0 '\000'        0 '\000'
(gdb) p *(int *)i_ptr
$21 = 8518
(gdb) p *(int *)subarray 
$22 = 8518

Hope this helps! Thanks!

from dmtcp.

JainTwinkle avatar JainTwinkle commented on June 28, 2024

I just realized that THREAD_REAL_PID returns the virtual PID, not the real PID. And that's why the PID field doesn't match in the pthread_desc that has the real_pid after TID.

(gdb) p tid_pid
$32 = {tid = 8518, pid = 40000}

Relevant backtrace:

#0  getpid () at pid/pidwrappers.cpp:126
#1  0x00007ffff7e8590c in syscall (sys_num=<optimized out>) at pid/pid_miscwrappers.cpp:332
#2  0x00007ffff7f09238 in _real_syscall (sys_num=<optimized out>) at syscallsreal.c:891
#3  0x00007ffff7ed1990 in _real_getpid () at threadlist.cpp:96
#4  dmtcp_get_real_pid () at threadlist.cpp:96
#5  0x00007ffff7ecccd7 in TLSInfo_GetTidOffset () at tls.cpp:227
...
(gdb) p _dmtcp_pid 
$37 = 40000

from dmtcp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.