Unable to find shared buffer for <TempTableName>. (566

Posted by Simon L. Prinsloo on 21-Jan-2015 02:22

OpenEdge 11.4 and 11.5.

I have a base class with a protected dataset.

In a derived class, some methods declares local buffers on the temp-tables and others take temp-table buffers as parameters. These explicit buffers (either DEFINE BUFFER or BUFFER parameters) often hides the default buffer by using the same name (e.g. DEFINE BUFFER ttCustomer FOR ttCustomer. or signature (BUFFER ttCustomer FOR ttCustomer).

Everything compiles, but at runtime I get the error:

<DerivedClassName> Unable to find shared buffer for <TempTableName>. (566)

Another weird issue, when I hit CTRL-SHIFT-O, the following line is inserted, but the code will compile with and without it:

USING System.Object FROM ASSEMBLY.

Any ideas as to how I need to proceed to solve this?

Posted by Simon L. Prinsloo on 23-Jan-2015 03:05

I believe you are right and logged case 00301640.

It seems that some (most) cases where buffers parameters are used for the protected dataset causes various errors. In some cases it works with 1 method receiving such a parameter, but causes the class to fail to load as soon as you add a second method taking a buffer parameter.

For those interested to see the behaviour, I have created the following 4 easy to reproduce test cases, using OE11.5 64-bit on Windows 8.1. I would be interested to know if it happens on 32-bit and/or lower versions as well.


In some cases, the code work as expected, but in many cases the AVM terminates with a stack dump or raises error 566 (<Class Name> Unable to find shared buffer for <table name>.) upon instantiation.


The various scenarios are as follows:

Preparation:
1. Create the following base class:

CLASS Base: 

    DEFINE PROTECTED TEMP-TABLE ttCustomer NO-UNDO
        FIELD custNum AS INTEGER 
        FIELD custName AS CHARACTER 
        INDEX custNum IS PRIMARY UNIQUE custnum.

END CLASS.

2. Create the following test routine:

DEFINE VARIABLE obj AS SubClass NO-UNDO.
MESSAGE 1 "Before Instantiation"
VIEW-AS ALERT-BOX.

obj = NEW SubClass().

MESSAGE 2 "After instantiation:" SKIP 
        obj
VIEW-AS ALERT-BOX.

obj:TestIt().

MESSAGE 3 "After Test:" SKIP 
VIEW-AS ALERT-BOX.

CATCH e AS Progress.Lang.Error :
    MESSAGE "ERROR Intercepted" SKIP
            "Number of messages:" e:NumMessages SKIP 
            e:GetMessage(1)
    VIEW-AS ALERT-BOX.
END CATCH.


Test Case 1:
1. Create the sub class:

CLASS SubClass INHERITS Base: 

    METHOD PUBLIC VOID TestIt ():
        TestA(BUFFER  ttCustomer).
    END METHOD.

    METHOD PRIVATE VOID TestA (BUFFER ttCustomer FOR ttCustomer):
        MESSAGE "TestA"
        VIEW-AS ALERT-BOX.
        
        RETURN.

    END METHOD .
END CLASS.
2. Run test.p

Result:  Success


Test Case 2:
1. Remove the call to TestA() in the TestIt() method of the sub class as below:

CLASS SubClass INHERITS Base: 

    METHOD PUBLIC VOID TestIt ():
        /*TestA(BUFFER  ttCustomer). - Removed*/
    END METHOD.

    METHOD PRIVATE VOID TestA (BUFFER ttCustomer FOR ttCustomer):
        MESSAGE "TestA"
        VIEW-AS ALERT-BOX.
        
        RETURN.

    END METHOD .

END CLASS.
2. Run test.p

Result:  Session failure with stack trace when executing "obj = NEW SubClass()." in test.p


Test Case 3:
1. Amend the sub class as below:

CLASS SubClass INHERITS Base: 

    METHOD PUBLIC VOID TestIt ():
        /*TestA(BUFFER  ttCustomer).*/
    END METHOD.

    METHOD PRIVATE VOID TestA (BUFFER ttCustomer FOR ttCustomer):
        DEFINE BUFFER bCust FOR ttCustomer. /* New Code */
        MESSAGE "TestA"
        VIEW-AS ALERT-BOX.
        
        RETURN.

    END METHOD .

END CLASS.

 
2. Run test.p

Result:  Success


Test Case 4:
1. Amend the sub class as below:

CLASS SubClass INHERITS Base: 

    METHOD PUBLIC VOID TestIt ():
        /*TestA(BUFFER  ttCustomer).*/
    END METHOD.

    METHOD PRIVATE VOID TestA (BUFFER ttCustomer FOR ttCustomer):
        DEFINE BUFFER bCust FOR ttCustomer.
        MESSAGE "TestA"
        VIEW-AS ALERT-BOX.
        
        RETURN.

    END METHOD .
/* New Method */ METHOD PRIVATE VOID TestB (BUFFER ttCustomer FOR ttCustomer): END METHOD . END CLASS.
2. Run test.p

Result:  Failure with error 566 when executing "obj = NEW SubClass()." in test.p

Playing around with other permutations of SubClass always render one of these results

All Replies

Posted by Fernando Souza on 22-Jan-2015 08:16

This sounds like a bug to me, but I would need to see the code that causes the error. You should probably open a call with support.

Posted by Simon L. Prinsloo on 23-Jan-2015 03:05

I believe you are right and logged case 00301640.

It seems that some (most) cases where buffers parameters are used for the protected dataset causes various errors. In some cases it works with 1 method receiving such a parameter, but causes the class to fail to load as soon as you add a second method taking a buffer parameter.

For those interested to see the behaviour, I have created the following 4 easy to reproduce test cases, using OE11.5 64-bit on Windows 8.1. I would be interested to know if it happens on 32-bit and/or lower versions as well.


In some cases, the code work as expected, but in many cases the AVM terminates with a stack dump or raises error 566 (<Class Name> Unable to find shared buffer for <table name>.) upon instantiation.


The various scenarios are as follows:

Preparation:
1. Create the following base class:

CLASS Base: 

    DEFINE PROTECTED TEMP-TABLE ttCustomer NO-UNDO
        FIELD custNum AS INTEGER 
        FIELD custName AS CHARACTER 
        INDEX custNum IS PRIMARY UNIQUE custnum.

END CLASS.

2. Create the following test routine:

DEFINE VARIABLE obj AS SubClass NO-UNDO.
MESSAGE 1 "Before Instantiation"
VIEW-AS ALERT-BOX.

obj = NEW SubClass().

MESSAGE 2 "After instantiation:" SKIP 
        obj
VIEW-AS ALERT-BOX.

obj:TestIt().

MESSAGE 3 "After Test:" SKIP 
VIEW-AS ALERT-BOX.

CATCH e AS Progress.Lang.Error :
    MESSAGE "ERROR Intercepted" SKIP
            "Number of messages:" e:NumMessages SKIP 
            e:GetMessage(1)
    VIEW-AS ALERT-BOX.
END CATCH.


Test Case 1:
1. Create the sub class:

CLASS SubClass INHERITS Base: 

    METHOD PUBLIC VOID TestIt ():
        TestA(BUFFER  ttCustomer).
    END METHOD.

    METHOD PRIVATE VOID TestA (BUFFER ttCustomer FOR ttCustomer):
        MESSAGE "TestA"
        VIEW-AS ALERT-BOX.
        
        RETURN.

    END METHOD .
END CLASS.
2. Run test.p

Result:  Success


Test Case 2:
1. Remove the call to TestA() in the TestIt() method of the sub class as below:

CLASS SubClass INHERITS Base: 

    METHOD PUBLIC VOID TestIt ():
        /*TestA(BUFFER  ttCustomer). - Removed*/
    END METHOD.

    METHOD PRIVATE VOID TestA (BUFFER ttCustomer FOR ttCustomer):
        MESSAGE "TestA"
        VIEW-AS ALERT-BOX.
        
        RETURN.

    END METHOD .

END CLASS.
2. Run test.p

Result:  Session failure with stack trace when executing "obj = NEW SubClass()." in test.p


Test Case 3:
1. Amend the sub class as below:

CLASS SubClass INHERITS Base: 

    METHOD PUBLIC VOID TestIt ():
        /*TestA(BUFFER  ttCustomer).*/
    END METHOD.

    METHOD PRIVATE VOID TestA (BUFFER ttCustomer FOR ttCustomer):
        DEFINE BUFFER bCust FOR ttCustomer. /* New Code */
        MESSAGE "TestA"
        VIEW-AS ALERT-BOX.
        
        RETURN.

    END METHOD .

END CLASS.

 
2. Run test.p

Result:  Success


Test Case 4:
1. Amend the sub class as below:

CLASS SubClass INHERITS Base: 

    METHOD PUBLIC VOID TestIt ():
        /*TestA(BUFFER  ttCustomer).*/
    END METHOD.

    METHOD PRIVATE VOID TestA (BUFFER ttCustomer FOR ttCustomer):
        DEFINE BUFFER bCust FOR ttCustomer.
        MESSAGE "TestA"
        VIEW-AS ALERT-BOX.
        
        RETURN.

    END METHOD .
/* New Method */ METHOD PRIVATE VOID TestB (BUFFER ttCustomer FOR ttCustomer): END METHOD . END CLASS.
2. Run test.p

Result:  Failure with error 566 when executing "obj = NEW SubClass()." in test.p

Playing around with other permutations of SubClass always render one of these results

This thread is closed