Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Callbacks and Timers » Strange crash connected to Timer
Strange crash connected to Timer [message #25764] Wed, 10 March 2010 21:39 Go to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Hi,

I've been getting regular but hard to repeat crashes so I let my software go in debug mode and found the attached call stack. I'm not sure if it is something I am doing or a slight bug in UPP that only I see because I run a function that looks like this

void OpenWind::OnTimer()
{
	// update the UI
	
	bool b = AreWeFree();
	
	m_pSaveButton->Enable(b);
	m_pNewButton->Enable(b);
	m_pEditButton->Enable(b);
	
	::SetTimeCallback(1000,THISBACK(OnTimer));	
}


in order to update the state of my toolbar buttons. As you can see, OnTimer is called every second for the whole time my software is running. The crash happens when I am running other threads concurrently. Am only posting this here because the call stack consists entirely of UPP code.

Nick
  • Attachment: callStack.png
    (Size: 44.39KB, Downloaded 397 times)

[Updated on: Wed, 10 March 2010 21:41]

Report message to a moderator

Re: Strange crash connected to Timer [message #25769 is a reply to message #25764] Thu, 11 March 2010 07:52 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nixnixnix wrote on Wed, 10 March 2010 15:39

Hi,

I've been getting regular but hard to repeat crashes so I let my software go in debug mode and found the attached call stack. I'm not sure if it is something I am doing or a slight bug in UPP that only I see because I run a function that looks like this

void OpenWind::OnTimer()
{
	// update the UI
	
	bool b = AreWeFree();
	
	m_pSaveButton->Enable(b);
	m_pNewButton->Enable(b);
	m_pEditButton->Enable(b);
	
	::SetTimeCallback(1000,THISBACK(OnTimer));	
}


in order to update the state of my toolbar buttons. As you can see, OnTimer is called every second for the whole time my software is running. The crash happens when I am running other threads concurrently. Am only posting this here because the call stack consists entirely of UPP code.

Nick



Well, my first guess would be that in some other thread you forgot to GuiLock.

Maybe it would be interesting to post here call stacks of all threads (in theide, you can easily achieve that - you can switch threads and you can also put the callstack into the clipboard).

Note:

::SetTimeCallback(-1000,THISBACK(OnTimer));


Negative time would repeat the callback, so there would be no need to reactivate it in OnTimer.

Mirek
Re: Strange crash connected to Timer [message #25789 is a reply to message #25769] Thu, 11 March 2010 19:05 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
How do I switch threads please? That would be great!
Re: Strange crash connected to Timer [message #25790 is a reply to message #25789] Thu, 11 March 2010 20:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nixnixnix wrote on Thu, 11 March 2010 13:05

How do I switch threads please? That would be great!


There is a DropList on the left side of callstack DropList with threadid...

Mirek
Re: Strange crash connected to Timer [message #25796 is a reply to message #25790] Fri, 12 March 2010 02:14 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Hi Mirek,

The other threads listed are all in either ntdll.dll or in USER32.dll. In each case there is no call stack to paste here, just an address within each dll. They are below:

thread ID | DLL | address
0x80c - this is the thread which was described in my original post
0x564 | USER32.dll | 0x768f7e47
0x610 | ntdll.dll | 0x77cf00fd
0xbf8 | USER32.dll | 0x768f7e47
0xf84 | ntdll.dll | 0x77cefd31
0xcf0 | ntdll.dll | 0x77cf1ee6

My app ran for almost 200 iterations before it hit this. Sometimes its as few as 13 iterations. Other times it can run for over 5000 iterations.

EDIT: how do I copy and paste the callstack please? I've tried various things but can't quite figure it out. Also, I have disabled the OnTimer method and still get the crashes. I think I have a better example to paste but it would be good to know how to copy the callstack.

EDIT2: I do not use GuiLock but I didn't think I needed to if I always use PostCallback to update the interface. Is this correct? What if I have several threads posting GUI related callbacks to a function in the main thread?

Nick

[Updated on: Fri, 12 March 2010 03:18]

Report message to a moderator

Re: Strange crash connected to Timer [message #25797 is a reply to message #25796] Fri, 12 March 2010 08:32 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nixnixnix wrote on Thu, 11 March 2010 20:14

Hi Mirek,

The other threads listed are all in either ntdll.dll or in USER32.dll. In each case there is no call stack to paste here, just an address within each dll. They are below:

thread ID | DLL | address
0x80c - this is the thread which was described in my original post
0x564 | USER32.dll | 0x768f7e47
0x610 | ntdll.dll | 0x77cf00fd
0xbf8 | USER32.dll | 0x768f7e47
0xf84 | ntdll.dll | 0x77cefd31
0xcf0 | ntdll.dll | 0x77cf1ee6

My app ran for almost 200 iterations before it hit this. Sometimes its as few as 13 iterations. Other times it can run for over 5000 iterations.

EDIT: how do I copy and paste the callstack please? I've tried various things but can't quite figure it out. Also, I have disabled the OnTimer method and still get the crashes. I think I have a better example to paste but it would be good to know how to copy the callstack.



Have tried to look into Debug menu?

Quote:


EDIT2: I do not use GuiLock but I didn't think I needed to if I always use PostCallback to update the interface. Is this correct?



Yes. But possible problem is that it is way too easy to call something that actually needs GuiLock. E.g. reading some data from some widget or doing some operation that access GUI. (Remember that problem last time with ImageDraw?)

Quote:


What if I have several threads posting GUI related callbacks to a function in the main thread?



That should not be a problem.
Re: Strange crash connected to Timer [message #25809 is a reply to message #25797] Fri, 12 March 2010 21:12 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Quote:


Have tried to look into Debug menu?



Strangely yes. I see copy backtrace and I see copy dissassembly (both of which I have tried) but I don't see copy callstack. I realise I am being dumb but perhaps you could walk me through this? I am using version 2203

I think I may have fixed it anyway - I was updating a separate window directly.

Cheers,

Nick

Re: Strange crash connected to Timer [message #25814 is a reply to message #25809] Sat, 13 March 2010 09:11 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nixnixnix wrote on Fri, 12 March 2010 15:12

Quote:


Have tried to look into Debug menu?



Strangely yes. I see copy backtrace and I see copy dissassembly (both of which I have tried) but I don't see copy callstack.



backtrace = callstack.

(It is term from gdb, I thought it is not confusing).

Quote:


I think I may have fixed it anyway - I was updating a separate window directly.



Wink

Mirek
Previous Topic: PostCallback executes 2 at once?
Next Topic: partial parametrizing of Callback<>
Goto Forum:
  


Current Time: Thu Mar 28 10:54:29 CET 2024

Total time taken to generate the page: 0.00895 seconds