Code Monkey home page Code Monkey logo

Comments (4)

abhinav92003 avatar abhinav92003 commented on June 3, 2024 1

You're right -- looks like I was chasing a red herring.

I can modify the expected output to expect either a 0 or 1 for that line.

from dynamorio.

abhinav92003 avatar abhinav92003 commented on June 3, 2024

Oh I think it's the SF:/opt/actions-runner/_work/dynamorio/dynamorio/suite/tests/linux/eintr.c line written by

dr_write_file(log, buf, ptr - buf);

from dynamorio.

jackgallagher-arm avatar jackgallagher-arm commented on June 3, 2024

The difference is this line:
output:

2024-04-04T21:14:23.5132299Z 206:   DA:126,0

expected:

2024-04-04T21:14:25.4889115Z 206:   DA:126,1

which corresponds to this code:

124:     pthread_mutex_lock(&lock);
125:     while (!child_ready)
126:         pthread_cond_wait(&condvar, &lock); // <-- Is this line not executed for some reason?
127:     child_ready = false;
128:     pthread_mutex_unlock(&lock);

from dynamorio.

jackgallagher-arm avatar jackgallagher-arm commented on June 3, 2024

Is this just a racy test? If the handler() has been called before the main thread gets to the while loop child_ready will already be set to true and the loop body won't be executed.

/*
 * test of restarted syscalls
 */

#include "tools.h"

#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include <pthread.h>

static pthread_cond_t condvar;
static bool child_ready;
static pthread_mutex_t lock;

static void
handler(int sig)
{
    print("in handler %d\n", sig);

    /* potentially unsafe but we risk it: we should be in our read syscall */
    pthread_mutex_lock(&lock);
    child_ready = true;
    pthread_cond_signal(&condvar);
    pthread_mutex_unlock(&lock);
}

/* snip */

int
main(int argc, char **argv)
{
    /* snip */

    /* test signal w/ handler */
    print("sending SIGUSR1\n");
    pthread_kill(thread, SIGUSR1);
                  /* <-- handler() is executed here, setting child_ready = true */
    pthread_mutex_lock(&lock);
    while (!child_ready) /* child_ready == true so the loop gets skipped */
        pthread_cond_wait(&condvar, &lock);
    child_ready = false;
    pthread_mutex_unlock(&lock);

    /* snip */

    return 0;
}

from dynamorio.

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.