[ale] Clones and printf()
Chris Fowler
cfowler at outpostsentinel.com
Thu Mar 21 18:57:48 EST 2002
I think I found one problem. Here is a snip
int *stack = (int *)malloc(CHILD_STACK_SIZE); // 4096
pid = clone(execTask, stack, SIGCHLD|CLONE_VM, task);
The manpages states that a stack grows down. Since I'm
passing a pointer to the begining of the stack it is possible for
the thread to write into the parents process. Corupting my
program. Is this correct? I looked at some sampels on the
internet and they do not show doing that.
http://www.linuxjournal.com/modules.php?op=modload&name=NS-articles/misc/ima
ges&file=5211l2
Maybe that example is wrong. Is there any *good* documentation
online on using threads effectively. Maybe a book? It is just awesome
to have multiple threads doing tasks and sharing data. It opens
up many possibilites. I have some great planes with this.
Thanks,
Chris
-----Original Message-----
From: Chris Fowler [mailto:cfowler at outpostsentinel.com]
To: ale at ale.org
Sent: Thursday, March 21, 2002 4:54 PM
To: ale at ale.org
Subject: [ale] Clones and printf()
Hello,
I've been working on a multithreaded program in which my parent keeps
getting SIGSEGV. It appears to
get this condition during an attempt to speak(). speak is a library call I
wrote that bacially does the
following
1) open syslog
2) creates a message using vsprintf
3) write to syslog
4) close syslog
Each excution of speak does those things. I read in a 2001 document that I
should avoid
printf's with clone. Does this still hold true? My data looks perfectly
allocated and it does
not appear that I have memory corruption but that could still be prossible.
I basically keep
track of drones in a linked list and keep track of tasks in a linked list.
Each drone gets assigned 1
task. Parent tracks the drones using the first list. drone keeps track of
data only in
the trak it is assigned. The parent and drones never write to the same
variable. Drone
modifies a field then parent knows to process data.
Thanks,
Chris
---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
More information about the Ale
mailing list