• garbage.c bug?

    From Enrico Maria Giordano@21:1/5 to All on Thu Aug 22 17:53:59 2024
    This loop never ends in some situation, Ron can you look at it?


    /* Step 3 - Call Cleanup Functions */

    pAlloc = s_pCurrBlock;
    do
    {
    if( s_pCurrBlock->used == s_uUsedFlag )
    {
    s_pCurrBlock->used |= HB_GC_DELETE;

    /* call the cleanup function - now for NON Blosks. */
    if( s_pCurrBlock->pFunc )
    {
    HB_TRACE( HB_TR_INFO, ( "Cleanup, %p", s_pCurrBlock ) );
    ( s_pCurrBlock->pFunc )( ( void * ) ( s_pCurrBlock + 1 ) );
    HB_TRACE( HB_TR_INFO, ( "DONE Cleanup, %p", s_pCurrBlock ) );
    }
    }

    s_pCurrBlock = s_pCurrBlock->pNext;
    }
    while( s_pCurrBlock && ( s_pCurrBlock != pAlloc ) );

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Thu Aug 22 19:50:55 2024
    Il 22/08/2024 17:53, Enrico Maria Giordano ha scritto:

    This loop never ends in some situation, Ron can you look at it?

    Please note that I can reproduce the problem (with a FWH/MSC64 sample),
    so any suggestions is very welcome. This is the sample:

    #include "Fivewin.ch"


    FUNCTION MAIN()

    LOCAL oServer := MARIA_CONNECT( "access data", .T. )

    TEST( oServer )

    ? "Before HB_GCALL()"

    HB_GCALL( .F. )

    ? "After HG_GCALL()"

    oServer:Close()

    ? "ALL OK"

    RETURN NIL

    STATIC FUNCTION TEST( oServer )

    LOCAL oRs := oServer:RowSet( "Select 1" )

    oRs:End()

    RETURN NIL

    With a call to HB_GCALL( .F. ) after oRs:End() the problem goes away.

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Fri Aug 23 09:53:21 2024
    Il 22/08/2024 17:53, Enrico Maria Giordano ha scritto:

                ( s_pCurrBlock->pFunc )( ( void * ) ( s_pCurrBlock + 1 ) );

    Commenting out this line the problem goes away. Just to give you as many
    hints as possible.

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Sun Sep 22 14:26:28 2024
    This is from garbage.c of Harbour, could it be the problem?

    /*
    * infinite loop can appear when we are executing clean-up functions
    * scanning s_pCurrBlock. It's possible that one of them will free
    * the GC block which we are using as stop condition. Only blocks
    * for which we set HB_GC_DELETE flag are guarded against releasing.
    * To avoid such situation first we are moving blocks which will be
    * deleted to separate list. It's additional operation but it can
    * even increase the speed when we are deleting only few percent
    * of all allocated blocks because in next passes we will scan only
    * deleted block list. [druzus]
    */

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Fri Sep 27 10:17:27 2024
    The crash is here:

    hb_vmSend( 0 );

    It is inside classes.c, function hb_clsFinalize(), any ideas?

    void hb_clsFinalize( PHB_ITEM pObject )
    {
    HB_THREAD_STUB

    USHORT uiClass;

    if( HB_IS_OBJECT( pObject ) )
    uiClass = pObject->item.asArray.value->uiClass;
    else
    /* TODO Error!
    */
    return;

    if( uiClass && uiClass <= s_uiClasses )
    {
    PCLASS pClass = s_pClasses + ( uiClass - 1 );

    if( pClass->pDestructor )
    {
    if( pClass->uiScope & HB_OO_CLS_DESTRUC_SYMB )
    {
    assert( hb_stack_ready );

    if( s_AllowDestructors /* && hb_stack_ready */ )
    {
    if( HB_IS_SYMBOL( hb_stackBaseItem() ) &&
    (
    hb_stackBaseItem()->item.asSymbol.pCargo->uiSuperClass == 0 || ( USHORT
    ) hb_stackBaseItem()->item.asSymbol.pCargo->uiSuperClass != uiClass ||
    ( HB_IS_ARRAY( hb_stackSelfItem() ) && hb_stackSelfItem()->item.asArray.value != pObject->item.asArray.value )
    ) && strcmp( hb_stackBaseItem()->item.asSymbol.value->szName,
    "__CLSINSTSUPER" ) )
    {
    /* To DISABLE GC here where no refernce to this
    object will cause GPF for double release!
    */
    BOOL bCollecting = hb_gcSetCollecting( TRUE ),
    bPop = TRUE;
    PHB_SYMB pDestructor = pClass->pDestructor->pMessage->pSymbol;

    /* Save the existing Return Value and Top Item if any.
    */
    if( HB_IS_ARRAY( &HB_VM_STACK.Return ) && HB_VM_STACK.Return.item.asArray.value == pObject->item.asArray.value )
    {
    /* Don't process HB_VM_STACK.Return!
    */
    bPop = FALSE;

    /* Save top item which can be processed at this moment
    */
    hb_stackPush();
    }
    else
    hb_vmPushState();

    hb_vmPushSymbol( pDestructor );
    hb_vmPush( pObject ); /* Do NOT Forward!!! */
    hb_vmSend( 0 );

    /* Restore the existing Return Value and Top Item if any.
    */
    if( bPop )
    hb_vmPopState();
    else
    /* Restore top item
    */
    hb_stackDec();

    hb_gcSetCollecting( bCollecting );
    }
    }
    else
    hb_errInternal( HB_EI_ERRUNRECOV, "Destructors disabled! Destructor of class: '%s' can't be executed.", pClass->szName, NULL );
    }
    }
    }
    }

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Fri Sep 27 11:17:25 2024
    pDestructor and pObject contain numbers, so appear valid (how can I
    check them?). pDestructor -> szName contains __DESTRUCTOR. What else can
    I check?

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)