On linux Tcl version of the test just crashes constantly in free, i have no other OSes here

(gdb) bt
#0  0xb7f0d410 in ?? ()
#1  0xb6cd1b78 in ?? ()
#2  0x00000006 in ?? ()
#3  0x00003746 in ?? ()
#4  0xb7d3f731 in raise () from /lib/libc.so.6
#5  0xb7d40f08 in abort () from /lib/libc.so.6
#6  0xb7d74e7b in __libc_message () from /lib/libc.so.6
#7  0xb7d7ab10 in malloc_printerr () from /lib/libc.so.6
#8  0xb7d7c1a9 in free () from /lib/libc.so.6
#9  0x080485d9 in MemThread (arg=0x0) at ttest.c:33
#10 0xb7e8943f in NewThreadProc (clientData=0x804a358)
at /home/vlad/src/ossweb/external/archlinux/tcl/src/tcl8.4.14/unix/../generic/tclEvent.c:1229
#11 0xb7d014a2 in start_thread () from /lib/libpthread.so.0
#12 0xb7dd5ede in clone () from /lib/libc.so.6

Zoran Vasiljevic wrote:
On 19.12.2006, at 20:42, Stephen Deasey wrote:

On 12/19/06, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
Right, with Ns_ functions it does not crash.

Zoran will be happy...  :-)



Not at all!

So, I would like to know exactly how to reproduce the problem
(what OS, machine, etc).
Furthermore I need all your test-code and eventually the gdb
trace of the crash, to start with.

Can you get all that for me?


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel


--
Vlad Seryakov
571 262-8608 office
[EMAIL PROTECTED]
http://www.crystalballinc.com/vlad/

#include <tcl.h>

#include <stdlib.h>
#include <memory.h>
#include <unistd.h>
#include <signal.h>
#include <pthread.h>

#define MemAlloc malloc
#define MemFree free

static int nbuffer = 16384;
static int nloops = 50000;
static int nthreads = 4;

static void *gPtr = NULL;
static Tcl_Mutex *gLock = NULL;

void MemThread(void *arg)
{
     int   i,n;
     void *ptr = NULL;

     for (i = 0; i < nloops; ++i) {
         n = 1 + (int) (nbuffer * (rand() / (RAND_MAX + 1.0)));
         if (ptr != NULL) {
             MemFree(ptr);
         }
         ptr = MemAlloc(n);
         if (n % 50 == 0) {
             Tcl_MutexLock(&gLock);
             if (gPtr != NULL) {
                 MemFree(gPtr);
                 gPtr = NULL;
             } else {
                 gPtr = MemAlloc(n);
             }
             Tcl_MutexUnlock(&gLock);
         }
     }
}

int main (int argc, char **argv)
{
     int i;
     Tcl_ThreadId *tids;

     tids = (Tcl_ThreadId *)malloc(sizeof(Tcl_ThreadId) * nthreads);

     for (i = 0; i < nthreads; ++i) {
         Tcl_CreateThread( &tids[i], MemThread, NULL, TCL_THREAD_STACK_DEFAULT, TCL_THREAD_JOINABLE);
     }
     for (i = 0; i < nthreads; ++i) {
         Tcl_JoinThread(tids[i], NULL);
     }
}

Reply via email to