From owner-freebsd-questions Mon Apr 9 10:59:33 2001 Delivered-To: freebsd-questions@freebsd.org Received: from snoopy.oit.edu (snoopy.OIT.EDU [140.211.135.12]) by hub.freebsd.org (Postfix) with ESMTP id 2DC7C37B422 for ; Mon, 9 Apr 2001 10:59:16 -0700 (PDT) (envelope-from longj@oit.edu) Received: from long ([140.211.141.121]) by snoopy.oit.edu (8.11.3/8.11.3/OIT-1.0) with SMTP id f39HwiY23599; Mon, 9 Apr 2001 10:58:47 -0700 (PDT) Message-ID: <02c201c0c0db$2cc73f00$798dd38c@oit.edu> From: "Jim Long" To: "Brian M. King" , References: <000b01c0bf22$14f70460$0d6e1842@King.rochester.rr.com> Subject: Re: C++ Date: Mon, 9 Apr 2001 10:55:10 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_02BF_01C0C0E3.8C456080" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This is a multi-part message in MIME format. ------=_NextPart_000_02BF_01C0C0E3.8C456080 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Are the your data structures thread safe? Dou you have good thread synch = built in? ----- Original Message -----=20 From: Brian M. King=20 To: freebsd-questions@FreeBSD.ORG=20 Sent: Saturday, April 07, 2001 6:17 AM Subject: C++ Hello. I am currently in the process of developing an IRCd in C++ = on FreeBSD and while I was creating some test code I discovered a = problem and no programmers that I know seem to have any ideas as to why = its happening. I have the main() opening a socket for listening and = accepting connections. I also have a threaded function (Using POSIX = threads) that reads data from all the sockets and stores it into an STL = Queue system. I then have several work threads running the same function = that reads from the STL Queue list to handle the data appropriatly. In = the first thread that reads from the sockes I am allocating the memory = for each container element using 'char *msg =3D new char[size]' .. The = problem I am having is in the worker threads that handle the queues I do = a 'char *msg; msg =3D MessageQueue.front(); MessageQueue.pop(); if (msg = !=3D NULL) { delete [] msg; }' When it tries to delete the allocated = memory I get the error 'Junk pointer, too high to make sense.' but I've = used this method before without a problem. I am running FreeBSD = 4.2-RELEASE and am compiling with g++ .. I am attaching the test program = I've written to develop the STL Container system I will need in the ircd = itself. To compile: g++ -pthread -Wall -g -o sin sin2.cpp To Run: ./sin Open a socket connection to the box this program is running on on port = 1600 and send data to it, you will see the error (Which occurs in the = queue_handler function). -Brian ------=_NextPart_000_02BF_01C0C0E3.8C456080 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Are the your data structures thread safe? Dou you = have good=20 thread synch built in?
----- Original Message -----
From:=20 Brian=20 M. King
To: freebsd-questions@FreeBSD.O= RG=20
Sent: Saturday, April 07, 2001 = 6:17=20 AM
Subject: C++

    Hello. I am = currently in the=20 process of developing an IRCd in C++ on FreeBSD and while I was = creating some=20 test code I discovered a problem and no programmers that I know seem = to have=20 any ideas as to why its happening. I have the main() opening a socket = for=20 listening and accepting connections. I also have a threaded function = (Using=20 POSIX threads) that reads data from all the sockets and stores it into = an STL=20 Queue system. I then have several work threads running the same = function that=20 reads from the STL Queue list to handle the data appropriatly. In the = first=20 thread that reads from the sockes I am allocating the memory for each=20 container element using 'char *msg =3D new char[size]' .. The problem = I am=20 having is in the worker threads that handle the queues I do a 'char = *msg; msg=20 =3D MessageQueue.front(); MessageQueue.pop(); if (msg !=3D NULL) { = delete [] msg;=20 }' When it tries to delete the allocated memory I get the error 'Junk = pointer,=20 too high to make sense.' but I've used this method before without a = problem. I=20 am running FreeBSD 4.2-RELEASE and am compiling with g++ .. I am = attaching the=20 test program I've written to develop the STL Container system I will = need in=20 the ircd itself.
 
To compile: g++ -pthread -Wall -g -o = sin=20 sin2.cpp
To Run: ./sin
 
Open a socket connection to the box = this program=20 is running on on port 1600 and send data to it, you will see the error = (Which=20 occurs in the queue_handler function).
 
-Brian
------=_NextPart_000_02BF_01C0C0E3.8C456080-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message