GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Sep 21, 2014 8:09 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Gdk:ERROR: assertion failed
PostPosted: Sun Jan 01, 2012 1:53 pm 
Offline

Joined: Sun Jan 01, 2012 1:37 pm
Posts: 4
I have created GTK+ application. When I am going to run it, it is producing the following error, not every time. some times it produces it at the begining of the new thread created. Can anybody explain me what this error is.....

**
Gdk:ERROR:/build/buildd/gtk+2.0-2.24.6/gdk/gdkregion-generic.c:1110:miUnionNonO: assertion failed: (y1 < y2)
Aborted


Top
 Profile  
 
 Post subject: Re: Gdk:ERROR: assertion failed
PostPosted: Tue Jan 03, 2012 12:11 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
Any idea where in your code it might occur or what function could be calling gdkregion-generic? You can run it through a debugging program like gdb to help narrow down things.


Top
 Profile  
 
 Post subject: Re: Gdk:ERROR: assertion failed
PostPosted: Tue Jan 03, 2012 6:46 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 745
Location: UK
Hi,

Since you said you are using threads and the errors happen only sometimes. Then your problem could be the threading system has not been correctly initialised for GTK/GDK and that you may also not be using the GDK lock when calling GTK or GDK functions from multiple threads. As a note GTK/GDK is thread aware, but not thread safe.

See the manual page at http://developer.gnome.org/gdk/stable/gdk-Threads.html

_________________
E.


Top
 Profile  
 
 Post subject: Re: Gdk:ERROR: assertion failed
PostPosted: Sat Jan 07, 2012 6:30 pm 
Offline

Joined: Sun Jan 01, 2012 1:37 pm
Posts: 4
Thank you and the problem has been solved.
my previous code was,

void power_on()
{
gdk_threads_init();
gtk_widget_show( pause_button );
pthread_t gui_thread;
if( pthread_create( &gui_thread, NULL, (void *)&start, NULL ) );
gtk_widget_hide( start_button );
}

now I changed it into,

void power_on()
{
g_thread_init(NULL);
gdk_threads_init();
gdk_threads_enter();
gtk_widget_show( pause_button );
pthread_t gui_thread;
if( pthread_create( &gui_thread, NULL, (void *)&start, NULL ) );
gtk_widget_hide( start_button );
gdk_threads_leave();
}

the problem should be the thread locks not working in the previous, but gdk_threads_enter() and gdk_threads_leave() functions solve that problem.


Top
 Profile  
 
 Post subject: Re: Gdk:ERROR: assertion failed
PostPosted: Sun Jan 08, 2012 10:06 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 745
Location: UK
Although this may have fixed your current problem I do not think you have used the GDK thread lock in the correct way and you may still have problems in the future, have a look at "Heisenbugs" and you may still have what is called a race condition.

This should really be called before gtk_init()
Code:
g_thread_init(NULL);
gdk_threads_init();
gdk_threads_enter();
to make sure that locking is see up within GTK/GDK correctly.

If you can avoid calling GTK/GDK from multiple threads that would ease your problems greatly and it can only be called from one thread at a time any way, so there is no performance to be gained there. Also calling GTK/GDK from multiple threads is only supported on the X11 back end.

_________________
E.


Top
 Profile  
 
 Post subject: Re: Gdk:ERROR: assertion failed
PostPosted: Thu Jan 26, 2012 6:46 pm 
Offline

Joined: Sun Jan 01, 2012 1:37 pm
Posts: 4
If I call gdk_threads_enter() before gtk_threads_init() without calling after, is it fix my complete problem out of this.


Top
 Profile  
 
 Post subject: Re: Gdk:ERROR: assertion failed
PostPosted: Thu Jan 26, 2012 7:30 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 745
Location: UK
You must initialise the internal mutexes of GTK/GDK using gdk_threads_init() before calling any other GTK or GDK function. Therefore the use of gdk_threads_enter() must be done after the call to gdk_threads_init().

_________________
E.


Top
 Profile  
 
 Post subject: Re: Gdk:ERROR: assertion failed
PostPosted: Sat Jan 28, 2012 11:34 am 
Offline

Joined: Sun Jan 01, 2012 1:37 pm
Posts: 4
In my previous code I posted, the function has been called in that way. What i didnt understand is, how race conditions happens in that code even thought functions have been called in that manner. please help me. I have no deep idea about gtk+....


Top
 Profile  
 
 Post subject: Re: Gdk:ERROR: assertion failed
PostPosted: Sun Jan 29, 2012 8:09 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 745
Location: UK
When using threads you must take care that the initialisation is done in the correct order, so that other library functions do not alter the internal state due to expecting something else to be there because the initialisation was done in the wrong order.

To quote the manual entry for gdk_threads_init()
Quote:
This call must be made before any use of the main loop from GTK+; to be safe, call it before gtk_init().
But no where in your code sample do you show that any of this is possible and that you must have done many more GTK calls before initialising the GDK threading system.

Using threads can be difficult at the best of times as without care you could create an application that works great on your system, but totally fails unexpectedly on another machine.

Take care and please take the time to read the manual page for the GDK threads http://developer.gnome.org/gdk/stable/gdk-Threads.html and take note of the line in the manual
Quote:
You must call g_thread_init() and gdk_threads_init() before executing any other GTK+ or GDK functions in a threaded GTK+ program.

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group