Date: Wed, 29 Jan 2003 01:51:29 -0600 From: Dan Nelson <dnelson@allantgroup.com> To: Murat Balaban <murat@enderunix.org> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: memcpy and multithreading Message-ID: <20030129075129.GK17299@dan.emsphone.com> In-Reply-To: <20030129092714.A86300@enderunix.org> References: <20030129092714.A86300@enderunix.org>
next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Jan 29), Murat Balaban said: > Are there any issues that i should now about memcpy and > multithreading in FreeBSD? I've got a code which reads: > > memcpy(&(h.req), req, sizeof(struct request)); What are the values of h and req at the time of segfault? You might want to try running with MALLOC_OPTIONS=J, which makes sure you don't accidentally use free'd memory, or assume that malloced memory is zeroed. If you see pointers with values near 0xD0D0D0D0, you have found a bug in your code... > and I keep getting SIGSEGV there in FreeBSD but not in Linux. > > PS: Of course, I protect the write operation with a mutex. Mutexes will protect you from someone stepping on your memory while you're copying. They don't protect you from seg faults if you have the wrong pointers in the first place. -- Dan Nelson dnelson@allantgroup.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030129075129.GK17299>
