I understood what you tried to do, what I didn't understand is how. Problem with mutli-threading is, it is very easy to confuse bad settings with code error of the libraries you call from it.

In my previous mail I have shown how the crash you reported could be avoided also with your settings.

However, I think this could be done in a better way. For example, if you have one searcher and many search threads, you can use a volatile bool to indicate whether or not the searcher has been deleted, which the threads check upon. You set it to true, wait on all threads to quit, and then delete the searcher object.

Itamar.

On 30/7/2010 6:04 PM, Kostka Bořivoj wrote:

Hi Itamar,

Please ignore the first block, I wanted to remove it before push, but I forgot…

What I tried to simulate is the situation the thread which calls IndexSearcher::search method ends

after IndexSearcher object is deleted. The logic in the test is, of course, stupid, but the

situation itself doesn’t need to be result of incorrect logic I think (eg. if you are using pool of working

threads on shared set of IndexSearchers and want to decrease number of IndexSearchers

without need to stop all working threads).

Borek

*From:* Itamar Syn-Hershko [mailto:ita...@divrei-tora.com]
*Sent:* Friday, July 30, 2010 1:32 PM
*To:* clucene-developers@lists.sourceforge.net
*Subject:* Re: [CLucene-dev] Exception during thread finish

Hi Borek,

I'm not sure I understand what you tried to do in the code you sent - especially with the deletion mutex. However, if I replace the line:

    CONDITION_WAIT(deleteMutex, deleteCondition);

>From your search function with

    _LUCENE_THREAD_FUNC_RETURN(0);

The second block of code runs just fine. If I don't comment out the first block, it seem to run indefinitely.

I'd say your code logic is incorrect. See how threading is done in TestThreading.cpp. You may want to implement the searcher deletion from the main thread managing the searcher threads instead of from the searcher threads themselves.

I tested with the atomicthreads branch only.

Itamar.

On 28/7/2010 1:34 PM, Kostka Bořivoj wrote:

Enclosed test reproduces the problem with master branch. Could anybody try it 
with atomicthreads?
Borek
    -----Original Message-----

    From: Kostka Bořivoj [mailto:kos...@tovek.cz]

    Sent: Tuesday, July 27, 2010 10:22 AM

    To:clucene-developers@lists.sourceforge.net  
<mailto:clucene-developers@lists.sourceforge.net>

    Subject: Re: [CLucene-dev] Exception during thread finish

    I'm trying to to write some simpe test which produces the problem now.

    It (probably) happens if thread calling _search finishes after related

    IndexSearcher is deleted

    Borek

        -----Original Message-----

        From: Itamar Syn-Hershko [mailto:ita...@code972.com]

        Sent: Monday, July 26, 2010 8:28 PM

        To:clucene-developers@lists.sourceforge.net  
<mailto:clucene-developers@lists.sourceforge.net>

        Subject: Re: [CLucene-dev] Exception during thread finish

        If you're sure this is not a race condition between your threads, try

        the atomicthreads branch. We fixed several threading errors there.

        Actually, if this resolves this issue, I might just go ahead and merge

        it to master and wait no more...

        Itamar.

        On 26/7/2010 3:51 PM, Kostka Bořivoj wrote:

            I run the IndexSearcher::_search method from separate thread 
(different from

    thread

        where IndexSearcher is created and deleted).

            When the thread finishes, I get exceptionin mutex_thread::lock() 
The reason is

        _internal is already deleted (contains 0xdddddddd).

            Any idea what could be wrong?

            Borek

            Call stack:

            clucene-sharedd.dll!lucene::util::mutex_thread::lock()  Line 50 + 
0x5 bytes

           C++

            clucene-

        
sharedd.dll!lucene::util::mutexGuard::mutexGuard(lucene::util::mutex_thread&

        rMutex={...})  Line 248  C++

            clucene-cored.dll!lucene::util::_ThreadLocal::setNull()  Line 139 + 
0x15 bytes

           C++

            clucene-cored.dll!lucene::util::ThreadLocals::UnregisterThread()  
Line 232

           C++

            
clucene-cored.dll!lucene::util::_ThreadLocal::UnregisterCurrentThread()  Line 
210

           C++

            clucene-cored.dll!DllMain(unsigned short hinstDLL=0, unsigned long

    fdwReason=3,

        void * __formal=0x00000000)  Line 37     C++

            clucene-cored.dll!__DllMainCRTStartup(void * hDllHandle=0x01010000, 
unsigned

        long dwReason=3, void * lpreserved=0x00000000)  Line 498 + 0x11 bytes   
  C

            clucene-cored.dll!_DllMainCRTStartup(void * hDllHandle=0x01010000, 
unsigned

        long dwReason=3, void * lpreserved=0x00000000)  Line 462 + 0x11 bytes   
  C

            ntdll.dll!_ldrpcallinitrout...@16()  + 0x14 bytes

            ntdll.dll!_ldrshutdownthr...@0()  + 0xed bytes

            kernel32.dll!_exitthr...@4()  + 0x3e bytes

            msvcr80d.dll!_endthreadex(unsigned int retcode=0)  Line 414 C

            msvcr80d.dll!_callthreadstartex()  Line 348 + 0x15 bytes    C

            msvcr80d.dll!_threadstartex(void * ptd=0x0164fc80)  Line 331 C

            kernel32.dll!_basethreadst...@8()  + 0x37 bytes

            
------------------------------------------------------------------------------

            The Palm PDK Hot Apps Program offers developers who use the

            Plug-In Development Kit to bring their C/C++ apps to Palm for a 
share

            of $1 Million in cash or HP Products. Visit us here for more 
details:

            http://ad.doubleclick.net/clk;226879339;13503038;l?

            http://clk.atdmt.com/CRS/go/247765532/direct/01/

            _______________________________________________

            CLucene-developers mailing list

            CLucene-developers@lists.sourceforge.net  
<mailto:CLucene-developers@lists.sourceforge.net>

            https://lists.sourceforge.net/lists/listinfo/clucene-developers

        
------------------------------------------------------------------------------

        The Palm PDK Hot Apps Program offers developers who use the

        Plug-In Development Kit to bring their C/C++ apps to Palm for a share

        of $1 Million in cash or HP Products. Visit us here for more details:

        http://ad.doubleclick.net/clk;226879339;13503038;l?

        http://clk.atdmt.com/CRS/go/247765532/direct/01/

        _______________________________________________

        CLucene-developers mailing list

        CLucene-developers@lists.sourceforge.net  
<mailto:CLucene-developers@lists.sourceforge.net>

        https://lists.sourceforge.net/lists/listinfo/clucene-developers

    
------------------------------------------------------------------------------

    The Palm PDK Hot Apps Program offers developers who use the

    Plug-In Development Kit to bring their C/C++ apps to Palm for a share

    of $1 Million in cash or HP Products. Visit us here for more details:

    http://ad.doubleclick.net/clk;226879339;13503038;l?

    http://clk.atdmt.com/CRS/go/247765532/direct/01/

    _______________________________________________

    CLucene-developers mailing list

    CLucene-developers@lists.sourceforge.net  
<mailto:CLucene-developers@lists.sourceforge.net>

    https://lists.sourceforge.net/lists/listinfo/clucene-developers

    
------------------------------------------------------------------------------

    The Palm PDK Hot Apps Program offers developers who use the

    Plug-In Development Kit to bring their C/C++ apps to Palm for a share

    of $1 Million in cash or HP Products. Visit us here for more details:

    http://ad.doubleclick.net/clk;226879339;13503038;l?

    http://clk.atdmt.com/CRS/go/247765532/direct/01/

    _______________________________________________

    CLucene-developers mailing list

    CLucene-developers@lists.sourceforge.net  
<mailto:CLucene-developers@lists.sourceforge.net>

    https://lists.sourceforge.net/lists/listinfo/clucene-developers


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm


_______________________________________________
CLucene-developers mailing list
CLucene-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/clucene-developers
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
CLucene-developers mailing list
CLucene-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/clucene-developers

Reply via email to