Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: Reference-counted pointer assignment failed; the left-hand and right-hand side types are incompatible (PKN3Ctl8RcObjectE, N3Ctl16SimdBinaryOpNodeE). #6

Closed
aforsythe opened this issue Jan 26, 2012 · 3 comments
Labels

Comments

@aforsythe
Copy link
Member

// BUG 1:
// Uncommenting the following results in a compilation error of:
//ImportError: Reference-counted pointer assignment failed; the left-hand and right-hand side types are incompatible (PKN3Ctl8RcObjectE, N3Ctl16SimdBinaryOpNodeE).
// const float COEFSX[ 9] = {
//    5.6648,  5.3418,  4.3937,  3.1748,  1.9663,  0.95155,  0.22244, -0.22149, -0.47615
// };
// const float KNOT_DENSX[ 8] = {
//    ( COEFSX[ 0] + COEFSX[ 1]) / 2.,
//    ( COEFSX[ 1] + COEFSX[ 2]) / 2.,
//    ( COEFSX[ 2] + COEFSX[ 3]) / 2.,
//    ( COEFSX[ 3] + COEFSX[ 4]) / 2.,
//    ( COEFSX[ 4] + COEFSX[ 5]) / 2.,
//    ( COEFSX[ 5] + COEFSX[ 6]) / 2.,
//    ( COEFSX[ 6] + COEFSX[ 7]) / 2.,
//    ( COEFSX[ 7] + COEFSX[ 8]) / 2.
// };

const float COEFS0 =  5.6648;
const float COEFS1 =  5.3418;
const float COEFS2 =  4.3937;
const float COEFS3 =  3.1748;
const float COEFS4 =  1.9663;
const float COEFS5 =  0.95155;
const float COEFS6 =  0.22244;
const float COEFS7 = -0.22149;
const float COEFS8 = -0.47615;
const float COEFS[ 9] = { COEFS0, COEFS1, COEFS2, COEFS3, COEFS4, COEFS5, COEFS6,
    COEFS7, COEFS8 };
const float KNOT_DENS[ 8] = {
    ( COEFS0 + COEFS1) / 2.,
    ( COEFS1 + COEFS2) / 2.,
    ( COEFS2 + COEFS3) / 2.,
    ( COEFS3 + COEFS4) / 2.,
    ( COEFS4 + COEFS5) / 2.,
    ( COEFS5 + COEFS6) / 2.,
    ( COEFS6 + COEFS7) / 2.,
    ( COEFS7 + COEFS8) / 2.
};

const float KNOTS[ 8] = { -3., -2.5, -2., -1.5, -1., -0.5, 0., 0.5 };
const float KNOT_DEL = 0.5;
const unsigned int LAST_KNOT = KNOTS.size - 1;
const float INDEX_MAP[ 8] = { 0., 1., 2., 3., 4., 5., 6., 7. };

const float NEG_SLOPE = 0.01;
const float HI_SLOPE = -0.5;
const float LO_SLOPE1 = 0.0254;
const float LO_BREAK1 = LO_SLOPE1 * 1e-5;
const float LO_SLOPE2 = ( -log10( LO_BREAK1) - KNOT_DENS[ 0]) / ( -5 - KNOTS[ 0]);
const float M[ 3][ 3] = {
    {  0.5, -1.0, 0.5 },
    { -1.0,  1.0, 0.0 },
    {  0.5,  0.5, 0.0 }
};

float rrt_shaper_fwd( float x)
{
    float y;
    if ( x <= 0.0)
        y = x * NEG_SLOPE;
    else if ( x <= 1e-5)
        y = x * LO_SLOPE1;
    else {
        float logh = log10( x);
        float dens;

        if ( logh <= KNOTS[ 0])
            dens = KNOT_DENS[ 0] - ( KNOTS[ 0] - logh) * LO_SLOPE2;
        else if ( logh >= KNOTS[ LAST_KNOT])
            dens = KNOT_DENS[ LAST_KNOT] + ( logh - KNOTS[ LAST_KNOT]) * HI_SLOPE;
        else {
            int j;

            // BUG 2:
            // This method will occasionally fail (apparently at random) with a message like:
            // ./rrt_shaper_fwd.ctl:74: Array index out of range (index = -1291845632, array size = 8).
            // but otherwise gives correct results.
            if ( 0) {
                j = 0;
                while ( logh > KNOTS[ j + 1]) {
                    j = j + 1;
                }
            }
            // This theoretically equivalent method always works.
            else {
                j = lookup1D( INDEX_MAP, KNOTS[ 0], KNOTS[ LAST_KNOT], logh);
            }

            float t = ( logh - KNOTS[ j]) / KNOT_DEL;
            float monomials[ 3] = { t * t, t, 1. };
            float coef_vec[ 3] = { COEFS[ j], COEFS[ j + 1], COEFS[ j + 2]};
            dens = dot_f3_f3( coef_vec, mult_f3_f33( monomials, M));
        }
        y = pow10( -dens);
    }
    return y;
}


void main( 
    input varying float rIn, 
    input varying float gIn, 
    input varying float bIn, 
    input varying float aIn, 
    output varying float rOut, 
    output varying float gOut, 
    output varying float bOut, 
    output varying float aOut
) 
{ 
    rOut = rrt_shaper_fwd( rIn);
    gOut = rrt_shaper_fwd( gIn);
    bOut = rrt_shaper_fwd( bIn);
    aOut = aIn;
}
@kgboreham kgboreham mentioned this issue Oct 23, 2012
scottdyer referenced this issue in scottdyer/aces-dev Nov 2, 2012
@scottdyer
Copy link
Contributor

Uncommenting the first section (and removing the X suffix on all the variables) does result in a segmentation fault, but I do not get the verbose error quoted here. Furthermore, after applying the suggested fix, I still get a segmentation fault.

So without being able to reproduce the original issue, it is difficult to determine if the suggested fix resolved the issue.

@kgboreham
Copy link
Contributor

I checked it again this morning. You're correct about the seg fault. This threw me off when I first tried reproducing the issue as well. The code has apparently changed since this issue was reported and the result is an uncaught exception. The exception if caught would have the description equivalent to the reported output.

When I apply the patch the segmentation fault goes away. I can demo the process for you if you like.

@aforsythe
Copy link
Member Author

Ken,

Please demonstrate for Scott so he's satisfied the bug is addressed.

Thanks
Alex

Alexander Forsythe - Imaging Engineering Manager - Science and Technology Council

Academy of Motion Picture Arts and Sciences - Tel 310-247-3000 x3310
Fax 310-247-3611 - www.oscars.org - aforsythe@oscars.org

On Nov 2, 2012, at 7:46 AM, Ken Boreham notifications@github.com
wrote:

I checked it again this morning. You're correct about the seg fault. This threw me off when I first tried reproducing the issue as well. The code has apparently changed since this issue was reported and the result is an uncaught exception. The exception if caught would have the description equivalent to the reported output.

When I apply the patch the segmentation fault goes away. I can demo the process for you if you like.


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants