public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "zakaria.ternane at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug breakpoints/29164] New: [Multithread] Finish never return when a breakpoint hit
Date: Sat, 21 May 2022 12:12:15 +0000	[thread overview]
Message-ID: <bug-29164-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=29164

            Bug ID: 29164
           Summary: [Multithread] Finish never return when a breakpoint
                    hit
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: breakpoints
          Assignee: unassigned at sourceware dot org
          Reporter: zakaria.ternane at gmail dot com
  Target Milestone: ---

Created attachment 14110
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14110&action=edit
Minimal Working Exemple

OS : macOS Monterey / Linux

Hello,

When using the finish command in a gdb session consisting of two
threads, the finish is never hit if a breakpoint is hit in the other
thread before hitting the finish point.

In the following example, I have two threads and I set breakpoints on
"pthread_mutex_lock" and on "pthread_join" (pthread lib).  When the
first breakpoint is hit (on pthread_mutex_lock), I send the ```finish```
command. Then, the "join" breakpoint is hit and the even using
continue, the finish is never call back again.

#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>

int val = 0;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

void* fa(__attribute__((unused)) void* unused){
    pthread_mutex_lock(&mutex);
    val++;
    pthread_mutex_unlock(&mutex);
    return NULL;

}

int main(){
    pthread_t t1;

    printf("Value = %d\n", val);

    pthread_create(&t1, NULL, &fa, NULL);

    val += 10;

    pthread_join(t1, NULL);

    printf("Value = %d\n", val);

    return 0;
}

Sincerely,

Zakaria Ternane

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2022-05-21 12:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-21 12:12 zakaria.ternane at gmail dot com [this message]
2022-05-21 12:13 ` [Bug breakpoints/29164] " zakaria.ternane at gmail dot com
2022-05-21 12:14 ` zakaria.ternane at gmail dot com

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=bug-29164-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).