Thread safe?

16 views
Skip to first unread message

fsphil

unread,
Oct 23, 2011, 5:07:41 PM10/23/11
to osm-gps-map
Hi all,

How thread safe is osm-gps-map?

I'm writing a little program for tracking objects on a map from data
being read in a background thread. Once in a while when drawing a
ground track the program will crash:

#0 0x4b5a6286 in g_type_check_instance_cast () from /lib/
libgobject-2.0.so.0
#1 0x0011c1a3 in osm_gps_map_print_tracks (map=0x80b7008)
at osm-gps-map-widget.c:1260
#2 osm_gps_map_map_redraw (map=0x80b7008) at osm-gps-map-widget.c:
1335
#3 0x483455d1 in ?? () from /lib/libglib-2.0.so.0
#4 0x483495bf in g_main_context_dispatch () from /lib/libglib-2.0.so.
0
#5 0x48349d30 in ?? () from /lib/libglib-2.0.so.0
#6 0x4834a457 in g_main_loop_run () from /lib/libglib-2.0.so.0
#7 0x456eaf0f in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#8 0x0804ad5b in main (argc=1, argv=0xbffff3f4) at habhound.c:386

My program is removing an old track and adding a new one from the
background thread. All this is done inside some gdk_threads_enter()
and gdk_threads_leave() calls.

Any thoughts?

Gordon JC Pearce

unread,
Oct 24, 2011, 2:58:24 AM10/24/11
to osm-g...@googlegroups.com
On Sun, 23 Oct 2011 14:07:41 -0700 (PDT)
fsphil <ph...@sanslogic.co.uk> wrote:

> Hi all,
>
> How thread safe is osm-gps-map?

I don't know, but I haven't had the crashes you've had.

> Any thoughts?

Yes, steal your code from

https://github.com/gordonjcp/aprsmap

This basically has a G_IO thread running to talk to an APRS-IS server, and plops down objects and tracks in the GUI thread.

--
Gordon JC Pearce MM0YEQ <gord...@gjcp.net>

Philip Heron

unread,
Oct 24, 2011, 10:54:26 AM10/24/11
to osm-g...@googlegroups.com
On 24/10/2011 07:58, Gordon JC Pearce wrote:
> Yes, steal your code from
>
> https://github.com/gordonjcp/aprsmap

I've already been looking at that :) It's working really well now.

But yea, I'll probably end up doing something similar to get the data
from the thread to the UI. Doing UI stuffs directly from another thread
is perhaps foolish.

-Phil

John Stowers

unread,
Oct 24, 2011, 3:30:11 PM10/24/11
to osm-g...@googlegroups.com

Yeah, this is a gtk limitation, not osm-gps-map per se.

John

>
> -Phil
>

Philip Heron

unread,
Oct 29, 2011, 8:15:58 PM10/29/11
to osm-g...@googlegroups.com

Just to follow up on this, I worked around it by using g_idle_add() to
pass the data into the main thread. The threads don't touch the UI at
all now and no more crashing.

-Phil

Reply all
Reply to author
Forward
0 new messages