From stdcxx-dev-return-1696-apmail-incubator-stdcxx-dev-archive=incubator.apache.org@incubator.apache.org Fri Jul 07 01:20:12 2006 Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 19426 invoked from network); 7 Jul 2006 01:20:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Jul 2006 01:20:12 -0000 Received: (qmail 88079 invoked by uid 500); 7 Jul 2006 01:20:11 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 88060 invoked by uid 500); 7 Jul 2006 01:20:11 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 88033 invoked by uid 99); 7 Jul 2006 01:20:11 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jul 2006 18:20:11 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [208.30.140.160] (HELO moroha.quovadx.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jul 2006 18:20:10 -0700 Received: from qxvcexch01.ad.quovadx.com (qxvcexch01.ad.quovadx.com [192.168.170.59]) by moroha.quovadx.com (8.13.6/8.13.4) with ESMTP id k671JJAV001511 for ; Fri, 7 Jul 2006 01:19:19 GMT Received: from [10.70.3.113] ([10.70.3.113]) by qxvcexch01.ad.quovadx.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 6 Jul 2006 19:19:50 -0600 Message-ID: <44ADB6CB.40202@roguewave.com> Date: Thu, 06 Jul 2006 19:20:11 -0600 From: Martin Sebor Organization: Rogue Wave Software User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050920 X-Accept-Language: en-us, en MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: Re: string methods thread safety References: <4D6A8407B7AC6F4D95B0E55C4E7C4C62047CF121@exmsk.moscow.vdiweb.com> <44AC6F96.9050305@roguewave.com> In-Reply-To: <44AC6F96.9050305@roguewave.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 07 Jul 2006 01:19:50.0770 (UTC) FILETIME=[71ADFD20:01C6A163] X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Martin Sebor wrote: > Anton Pevtsov wrote: [...] >> I found the tricky place in the rwthread.cpp, line 397: >> void* const next_arg = thr_arg ? thr_arg + i : (void*)(thr_id + >> i); >> I suspect here should be >> void* const next_arg = thr_arg ? *(thr_arg + i) : (void*)(thr_id >> + i); >> The fix included. > > > Let me look into this tomorrow. I put together a test to help me understand the problem (see below) but I don't see anything wrong with its output. Do you? (Btw., we should probably rename rwthread.h and rwthread.cpp to rw_thread.h and thread.cpp for consistency with the rest of the driver source files.) Martin $ cat v.cpp && nice make v && ./v #include #include void* thr_func (void *arg) { void* const* const parg = (void**)arg; printf ("%p, %p\n", parg, *parg); return *parg; } void test (bool arg) { rw_thread_t thr_id [4]; static const unsigned nthrs = sizeof thr_id / sizeof *thr_id; void* thr_arg [nthrs] = { 0, 0, 0, 0 }; if (arg) { thr_arg [0] = (void*)0xa; thr_arg [1] = (void*)0xb; thr_arg [2] = (void*)0xc; thr_arg [3] = (void*)0xd; }; printf ("invoking rw_thread_pool() with a %snull thread argument\n", arg ? "non-" : ""); rw_thread_pool (thr_id, nthrs, 0, thr_func, arg ? thr_arg : 0); void* thr_res [nthrs] = { 0, 0, 0, 0 }; for (unsigned i = 0; i != nthrs; ++i) { rw_thread_join (thr_id [i], thr_res + i); printf ("thread %u result = %p\n", i, thr_res [i]); } } int main () { test (false); test (true); } gcc -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG -pthreads -D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/include -I/build/sebor/gcc-4.1.0-15s/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include -pedantic -nostdinc++ -g -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long v.cpp v.cpp: In function 'void* thr_func(void*)': v.cpp:8: warning: format '%p' expects type 'void*', but argument 2 has type 'void* const*' gcc v.o -o v -L/build/sebor/gcc-4.1.0-15s/rwtest -lrwtest15s -pthreads -L/build/sebor/gcc-4.1.0-15s/lib -lstd15s -lsupc++ -lm invoking rw_thread_pool() with a null thread argument ffbffa48, 0 ffbffa54, 1 ffbffa6c, 3 ffbffa60, 2 thread 0 result = 0 thread 1 result = 1 thread 2 result = 2 thread 3 result = 3 invoking rw_thread_pool() with a non-null thread argument ffbffa88, a ffbffa90, c ffbffa8c, b thread 0 result = a thread 1 result = b thread 2 result = c ffbffa94, d thread 3 result = d