<p></p>
<p dir="auto"><a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/nomadbyte/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/nomadbyte">@nomadbyte</a></p>
<p dir="auto">I tested your fix with the sample thread2.c (attached). Here are my findings:</p>
<ol dir="auto">
<li>No more hangs (fixed!)</li>
<li>It now debugs the thread in the same context, well, that depends on the concept, let me try to explain below:</li>
</ol>
<p dir="auto">Threads are not predictable, but in the sample, Thread[0] will always finish first, because it is fired first, in theory.</p>
<p dir="auto"><strong>First run:</strong></p>
<pre><code>./thread2
Thread[0] created successfully
Thread[0] processing...
Inside First thread: Thread[0]
Thread[1] created successfully
Thread[1] processing...
Inside Second thread: Thread[1]
Thread[0]: 0x7f102b58b700 [ x = 0xFFFFFFFF ]
Thread[0] finished successfully with status: 0
Thread[1]: 0x7f102ad8a700 [ x = 0xFFFFFFFF ]
Thread[1] finished successfully with status: 1
</code></pre>
<p dir="auto"><strong>Second run:</strong></p>
<pre><code>./thread2
Thread[0] processing...
Inside First thread: Thread[0]
Thread[0] created successfully
Thread[1] created successfully
Thread[1] processing...
Inside Second thread: Thread[1]
Thread[0]: 0x7f6cbc155700 [ x = 0xFFFFFFFF ]
Thread[0] finished successfully with status: 0
Thread[1]: 0x7f6cbb954700 [ x = 0xFFFFFFFF ]
Thread[1] finished successfully with status: 1
</code></pre>
<p dir="auto">So we can assume that. Maybe <strong>printf</strong> is not the best thing to use in the example.</p>
<p dir="auto">Now let's build and put a breakpoint on lines 25 and 34.<br>
Add variable <strong>i</strong> to Watch and debug.<br>
In my assumption, if I am right, when the first thread (Thread[0] or Thread[1] does not matter which one) hit the breakpoint (line 25) and you now can watch the value of <strong>i</strong>, if you do a <strong>[Step Over]</strong> and since we should be in the same context, variable <strong>i</strong> should not change until we exit the thread. Why? because we want to debug this thread (the first hit).</p>
<p dir="auto">But it switches to the new context when the next thread hits the breakpoint (line 25) and if you keep pushing <strong>[Step Over]</strong> until the end of the thread, you can notice variable <strong>i</strong> does not change, but we are now on next thread context.</p>
<p dir="auto">I think the next breakpoint hit on line 25 should be ignored and we should stay on the previous context until we exit from the thread.</p>
<p dir="auto">I will port this sample to Visual C and compare the results and mark this Closed or make any new comments.</p>
<p dir="auto">If anyone would like to comment on the assumption, please, be free to do so.</p>
<p dir="auto">Anyway, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/nomadbyte/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/nomadbyte">@nomadbyte</a> thank you for your work.<br>
<a href="https://github.com/geany/geany-plugins/files/8410529/thread2.c.zip">thread2.c.zip</a></p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/geany/geany-plugins/issues/1069#issuecomment-1087630994">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJ6SZGYYWSILMRINJO3VDL4EJANCNFSM4YQPZN7A">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAIOWJ3MYEOFZIV4C6ZUIILVDL4EJA5CNFSM4YQPZN7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIDJ65EQ.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><geany/geany-plugins/issues/1069/1087630994</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany-plugins/issues/1069#issuecomment-1087630994",
"url": "https://github.com/geany/geany-plugins/issues/1069#issuecomment-1087630994",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>