Re: [Fwd: dereferencing void *]
- From: Joël Krähemann <joel weedlight ch>
- To: Colomban Wendling <lists ban herbesfolles org>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: [Fwd: dereferencing void *]
- Date: Mon, 24 Mar 2014 10:17:08 +0100
On Mon, 2014-03-24 at 02:43 +0100, Colomban Wendling wrote:
Le 24/03/2014 01:36, Joël Krähemann a écrit :
[...]
The following will compile but is it still correct?
g_atomic_pointer_set(&(returnable_thread->safe_data),
NULL);
Yes, as the atomic_int* functions expect a pointer to the integer to
atomically set, the atomic_pointer* ones expect a pointer to the pointer
to atomically set.
Cheers,
Colomban
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Thank you very much but g_atomic_pointer_set doesn't help me in this
case. It still crashes with:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffddffb700 (LWP 25872)]
ags_task_thread_append_task_queue (thread=0x97a010)
at ./src/ags/thread/ags_task_thread.c:266
266 task_thread = append->task_thread;
(gdb) bt
#0 ags_task_thread_append_task_queue (thread=0x97a010)
at ./src/ags/thread/ags_task_thread.c:266
#1 0x00007ffff4bca2df in ?? ()
from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#2 0x00007ffff4be2df8 in g_signal_emit_valist ()
from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#3 0x00007ffff4be3a52 in g_signal_emit ()
from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#4 0x00000000004aec46 in ags_thread_run (thread=0x97a010)
at ./src/ags/thread/ags_thread.c:1718
#5 0x00000000004aefd7 in ags_thread_loop (ptr=<optimized out>)
at ./src/ags/thread/ags_thread.c:1641
#6 0x00007ffff377a062 in start_thread (arg=0x7fffddffb700) at
pthread_create.c:312
#7 0x00007ffff34aea3d in clone ()
at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
Here's what it does any idea why?
void
ags_task_thread_append_tasks_queue(AgsThread *thread)
{
AgsTask *task;
AgsTaskThread *task_thread;
AgsTaskThreadAppend *append;
GList *list;
gboolean initial_wait;
int ret;
append = (AgsTaskThreadAppend *)
g_atomic_pointer_get(&(AGS_RETURNABLE_THREAD(thread)->safe_data));
task_thread = append->task_thread;
list = (GList *) append->data;
free(append);
/* lock */
pthread_mutex_lock(&(task_thread->read_mutex));
/* append to queue */
task_thread->queued += g_list_length(list);
task_thread->queue = g_list_concat(task_thread->queue, list);
/* */
pthread_mutex_unlock(&(task_thread->read_mutex));
/* give back to pool */
ags_thread_stop(thread);
}
void
ags_task_thread_append_tasks(AgsTaskThread *task_thread, GList *list)
{
AgsTaskThreadAppend *append;
AgsThread *thread;
g_message("tasks\0");
append = (AgsTaskThreadAppend *) malloc(sizeof(AgsTaskThreadAppend));
append->task_thread = task_thread;
append->data = list;
thread = ags_thread_pool_pull(task_thread->thread_pool);
g_atomic_pointer_set(&(AGS_RETURNABLE_THREAD(thread)->safe_data),
append);
ags_thread_lock(thread);
AGS_THREAD_GET_CLASS(thread)->run =
ags_task_thread_append_tasks_queue;
ags_thread_lock(thread);
ags_thread_start(thread);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]