All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Bowman <jbowman@facts-inc.com>
To: xenomai@xenomai.org
Subject: [Xenomai] latency.c: fix occasional SIGSEGV at shutdown when mode is USER_TASK
Date: Sat, 1 Apr 2017 02:25:09 -0400	[thread overview]
Message-ID: <CAGTNcBtzrhyCvWycQGo+G_gyDjK17jWCGudszBNgF1Uv=9pmcA@mail.gmail.com> (raw)

Hi,

Under Mercury, I've been seeing occasionally a "Segmentation fault" message
when I hit ctrl-c to stop the latency test program. I caught a core dump,
and the stack trace leads back to the sem_wait() call in the display task.

I think this is caused by the cleanup() routine destroying the semaphore
before it calls join on the display task. This patch seems to fix the issue.

-Josh

diff --git a/testsuite/latency/latency.c b/testsuite/latency/latency.c
index e800361..5304342 100644
--- a/testsuite/latency/latency.c
+++ b/testsuite/latency/latency.c
@@ -492,6 +492,8 @@ static void cleanup(void)
     if (test_mode == USER_TASK) {
         pthread_cancel(latency_task);
         pthread_join(latency_task, NULL);
+        pthread_join(display_task, NULL);
+
         sem_close(display_sem);
         sem_unlink(sem_name);
         gavgjitter /= (test_loops > 1 ? test_loops : 2) - 1;
@@ -504,10 +506,9 @@ static void cleanup(void)
         gmaxjitter = overall.result.max;
         gavgjitter = overall.result.avg;
         goverrun = overall.result.overruns;
+        pthread_join(display_task, NULL);
     }

-    pthread_join(display_task, NULL);
-
     if (benchdev >= 0)
         close(benchdev);

             reply	other threads:[~2017-04-01  6:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-01  6:25 Josh Bowman [this message]
2017-04-01  9:16 ` [Xenomai] latency.c: fix occasional SIGSEGV at shutdown when mode is USER_TASK Philippe Gerum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGTNcBtzrhyCvWycQGo+G_gyDjK17jWCGudszBNgF1Uv=9pmcA@mail.gmail.com' \
    --to=jbowman@facts-inc.com \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.