# 2013 R3 is not usable for production apps for me

**URL:** <https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132>\
**Category:** General\
**Created:** [September 22, 2013, 3:42pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132 "2013-09-22T15:42:23Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [September 23, 2013, 8:56am UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/41 "2013-09-23T08:56:56Z")

</div>

Agree with the cursing…

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [September 23, 2013, 8:57am UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/42 "2013-09-23T08:57:18Z")

</div>

cursing

---

<div class="post-metadata">

**Author:** ![Mike\_D](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_d/32/266_2.png) [@Mike\_D](https://forum.xojo.com/u/Mike_D)\
**Post date:** [September 23, 2013, 3:20pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/43 "2013-09-23T15:20:37Z")

</div>

> [@35779:@Thomas Tempelmann](#):
>
> Besides, yesterday I found that Threads do not play well with the Profiler - I get useless results. Also, it leads to crashes when killing threads because the Profiler code seems to change the app’s behavior. Sigh.

Profiler & Threads: I submitted this in October 2009: \<[https://xojo.com/issue/10072](https://xojo.com/issue/10072)\> Is that what you are seeing?  
Profiler & Crashes: there was a nasty bug where profiled code would crash (if it was sufficiently complex and involved threads). I’m pretty sure it was fixed, but I can’t find my original bug report (Feedback + Merged reports = ‘who moved my cheese’).

---

<div class="post-metadata">

**Author:** ![Mike\_D](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_d/32/266_2.png) [@Mike\_D](https://forum.xojo.com/u/Mike_D)\
**Post date:** [September 23, 2013, 3:23pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/45 "2013-09-23T15:23:24Z")

</div>

Threads + Semaphore - I’ll admit I don’t use semaphores at all, so this may be a dumb questions, but…

What should this code do?

```auto
Pushbutton1.action
  self.mSem = new Semaphore
  mSem.Signal // acquire lock
  Thread1.run
end

Thread1.Run
  self.mSem.signal // this should block the thread, right?
  while true
      dim x as integer = 42
      
  wend

```

Testing this code, I find that Thread1 runs normally - it doesn’t stop at the Signal line. Am I misunderstanding how semaphores work?

---

<div class="post-metadata">

**Author:** ![Mike\_D](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_d/32/266_2.png) [@Mike\_D](https://forum.xojo.com/u/Mike_D)\
**Post date:** [September 23, 2013, 3:23pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/46 "2013-09-23T15:23:52Z")

</div>

Wow, the forum software is really misbehaving this morning.

---

<div class="post-metadata">

**Author:** ![Mike\_D](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_d/32/266_2.png) [@Mike\_D](https://forum.xojo.com/u/Mike_D)\
**Post date:** [September 23, 2013, 3:32pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/47 "2013-09-23T15:32:21Z")

</div>

Forum note: I just lost a post (clicked Post a Reply and nothing happened). Hitting the Back button (Safari 6) restored my post so I was able to copy/paste and re-submit it. Frustrating.

---

<div class="post-metadata">

**Author:** ![Jim\_Cramer](https://forum.xojo.com/user_avatar/forum.xojo.com/jim_cramer/32/2268_2.png) [@Jim\_Cramer](https://forum.xojo.com/u/Jim_Cramer)\
**Post date:** [September 23, 2013, 6:17pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/48 "2013-09-23T18:17:01Z")

</div>

[quote]Ok, I can conclusively say this has nothing to do with Thread.Sleep().

A trivial example shows this:

Thread1.Run  
while true  
dim x as integer = 42  
wend

Window1.open  
Thread1.Run

Pushbutton1.Action  
Thread1.Suspend  
Result:  
Still uses 80% CPU in 2013 R3 even after the thread is Suspended.[/quote]  
Using the above example, I can confirm the high CPU usage for suspended threads in when compiling with Xojo 2013r3 on OSX 10.8. For Windows 7x64, Thread.Suspend seems to be working as it should.

---

<div class="post-metadata">

**Author:** ![Jim\_Cramer](https://forum.xojo.com/user_avatar/forum.xojo.com/jim_cramer/32/2268_2.png) [@Jim\_Cramer](https://forum.xojo.com/u/Jim_Cramer)\
**Post date:** [September 23, 2013, 6:18pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/49 "2013-09-23T18:18:43Z")

</div>

Yep, something wrong with the forums.

---

<div class="post-metadata">

**Author:** ![Mike\_D](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_d/32/266_2.png) [@Mike\_D](https://forum.xojo.com/u/Mike_D)\
**Post date:** [September 24, 2013, 2:58pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/50 "2013-09-24T14:58:20Z")

</div>

> [@35936:@Jim Cramer](#):
>
> Using the above example, I can confirm the high CPU usage for suspended threads in when compiling with Xojo 2013r3 on OSX 10.8. For Windows 7x64, Thread.Suspend seems to be working as it should.

Were you testing on 1-core or 2+ core CPU for Windows 7? (this may not matter much as 29327 is marked as “fixed” already).

---

<div class="post-metadata">

**Author:** ![Jim\_Cramer](https://forum.xojo.com/user_avatar/forum.xojo.com/jim_cramer/32/2268_2.png) [@Jim\_Cramer](https://forum.xojo.com/u/Jim_Cramer)\
**Post date:** [September 24, 2013, 3:03pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/52 "2013-09-24T15:03:00Z")

</div>

> [@36154:@Michael Diehr](#):
>
> Were you testing on 1-core or 2+ core CPU for Windows 7? (this may not matter much as 29327 is marked as “fixed” already).

Michael,

I should have stated this was an 8 core Win7x64 machine. The Mac was a 4 core MBP.

---

<div class="post-metadata">

**Author:** ![Maurizio\_Rossi](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@Maurizio\_Rossi](https://forum.xojo.com/u/Maurizio_Rossi)\
**Post date:** [September 24, 2013, 5:45pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/54 "2013-09-24T17:45:26Z")

</div>

Michael,

I have reported problems on semaphores on feedback case #29677 and Xojo Pro channel (Inconsistent semaphore behavior can lead to app crash).

Semaphores works differently if the applications has one or more thread running.  
In some cases the main thread can cause an application crash.  
The sempahore problem seems not related to R3 but happens also in R2.

---

<div class="post-metadata">

**Author:** ![Maurizio\_Rossi](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@Maurizio\_Rossi](https://forum.xojo.com/u/Maurizio_Rossi)\
**Post date:** [September 24, 2013, 5:52pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/55 "2013-09-24T17:52:36Z")

</div>

Michael,

I have reported problems with sempahore on Xojo Pro channel (Inconsistent semaphore behavior can lead to app crash) and feedback case #29677.

Semaphore behave differently when one or more threads are running.  
In some cases the main thread can crash the application when using semaphore.  
The problem exist before 2013R3.

---

<div class="post-metadata">

**Author:** ![Mike\_D](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_d/32/266_2.png) [@Mike\_D](https://forum.xojo.com/u/Mike_D)\
**Post date:** [September 24, 2013, 8:11pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/56 "2013-09-24T20:11:09Z")

</div>

[quote=36203:@Maurizio Rossi]Michael,  
I have reported problems on semaphores on feedback case #29677 and Xojo Pro channel (Inconsistent semaphore behavior can lead to app crash).Semaphores works differently if the applications has one or more thread running.  
In some cases the main thread can cause an application crash.  
The sempahore problem seems not related to R3 but happens also in R2.[/quote]

Thanks - I don’t personally use Semaphores, but that seems like another critical bug to get fixed.

---

<div class="post-metadata">

**Author:** ![Maurizio\_Rossi](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@Maurizio\_Rossi](https://forum.xojo.com/u/Maurizio_Rossi)\
**Post date:** [September 24, 2013, 8:48pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/57 "2013-09-24T20:48:45Z")

</div>

This forum works strange when editing…  
Sometimes messages get lost or duplicated or…

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [September 25, 2013, 4:52am UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/58 "2013-09-25T04:52:23Z")

</div>

[quote=36207:@Maurizio Rossi]Michael,

I have reported problems with sempahore on Xojo Pro channel (Inconsistent semaphore behavior can lead to app crash) and feedback case #29677.

Semaphore behave differently when one or more threads are running.  
In some cases the main thread can crash the application when using semaphore.  
The problem exist before 2013R3.[/quote]  
I’m not sure what your expectations are for the example you submitted BUT the bug here actually seems to be that NOT having a secondary thread should also raise an exception since signaling on the main thread & signaling again should lock your app up leaving it with no threads to run - so the scheduler should raise an exception and your app should die.  
It’s not doing that.

That IS what is correctly killing the example WITH the secondary thread. All threads are waiting and so there is no “next available thread to run” so you have caused a deadlock in the app and there is NO way to revive it or release the deadlocks. So it dies.  
The thread scheduler fails to find anything that can be run so it raises an exception saying “there are no threads that can be run” and the app dies.

Its kind of an odd edge case.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [September 25, 2013, 4:54am UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/59 "2013-09-25T04:54:38Z")

</div>

[quote=36207:@Maurizio Rossi]Michael,

I have reported problems with sempahore on Xojo Pro channel (Inconsistent semaphore behavior can lead to app crash) and feedback case #29677.

Semaphore behave differently when one or more threads are running.  
In some cases the main thread can crash the application when using semaphore.  
The problem exist before 2013R3.[/quote]

Its an odd edge case.  
This sample should die in both cases as all threads are ineligible to run.  
The bug seems to be that it does NOT die when there are no secondary threads running.

---

<div class="post-metadata">

**Author:** ![Maurizio\_Rossi](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/ba8739/32.png) [@Maurizio\_Rossi](https://forum.xojo.com/u/Maurizio_Rossi)\
**Post date:** [September 25, 2013, 7:06am UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/60 "2013-09-25T07:06:24Z")

</div>

Hi Norman,

the scheduler or framework must raise an exception on illegal semaphore actions.  
The application simply must not die losing control of itself.  
I prefer a viable way to react to a fault instead of dying.

This is what I was reporting.

What is the intended use of things like exceptions and try/catch instructions?

---

<div class="post-metadata">

**Author:** ![Thomas\_Tempelmann](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_tempelmann/32/315_2.png) [@Thomas\_Tempelmann](https://forum.xojo.com/u/Thomas_Tempelmann)\
**Post date:** [September 25, 2013, 7:29am UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/61 "2013-09-25T07:29:06Z")

</div>

Michael, your example with the Semaphore is almost what I had in mind.  
Just one change: Instead of locking (i.e. calling Signal) in the main thread, call it twice in the running thread: Once initially, once when you want to suspend it. Then, in the main thread, where you want to Resume the thread, unlock the Semaphore.

Though, even if that works, I believe it won’t help the issuue with the 100% CPU usage.

Instead, the only work-around for this is to leave the thread’s Run method entirely when you want to suspend, and restart (.Run) it again when you want to resume it. If you have several code points at which you’d Suspend your thread, you’d then have to carry a thread-local state variable that jumps back to the point where you had the Suspend before. I realize that this works only in simple code case but not, for instance, in a more complex scheduler.

---

<div class="post-metadata">

**Author:** ![Thomas\_Tempelmann](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_tempelmann/32/315_2.png) [@Thomas\_Tempelmann](https://forum.xojo.com/u/Thomas_Tempelmann)\
**Post date:** [September 25, 2013, 7:29am UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/62 "2013-09-25T07:29:26Z")

</div>

curse curse curse

---

<div class="post-metadata">

**Author:** ![Mike\_D](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_d/32/266_2.png) [@Mike\_D](https://forum.xojo.com/u/Mike_D)\
**Post date:** [September 25, 2013, 3:43pm UTC](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132/63 "2013-09-25T15:43:24Z")

</div>

Norman, Thom, anyone from Xojo - can you comment on the feasibility / timing of fixing [https://xojo.com/issue/29633](https://xojo.com/issue/29633) ? If it’s not going to be fixed in 3.1, then I will probably have to spend time trying to come up with workarounds, such as suggested by Thomas and others (instead of sleeping threads, have them exit the Run loop, then have another Event which calls the .Run method again)

[Previous page](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132.md?page=2)

[Next page](https://forum.xojo.com/t/2013-r3-is-not-usable-for-production-apps-for-me/11132.md?page=4)
