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

get_system_attribute function seg default #66

Closed
jennwuu opened this issue Mar 6, 2021 · 4 comments
Closed

get_system_attribute function seg default #66

jennwuu opened this issue Mar 6, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@jennwuu
Copy link
Contributor

jennwuu commented Mar 6, 2021

int EXPORT_OUT_API SMO_getSystemAttribute(SMO_Handle p_handle, int periodIndex,
    SMO_systemAttribute attr, float **outValueArray, int *length)
//
//  Purpose: For the system at given time, get a particular attribute.
//
{
    int     errorcode = 0;
    float   temp;
    data_t *p_data;

    p_data = (data_t *)p_handle;

    if (p_data == NULL)
        errorcode = -1;
    else if (periodIndex < 0 || periodIndex >= p_data->Nperiods)
        errorcode = 422;
    else {
        // don't need to loop since there's only one system
        temp = getSystemValue(p_data, periodIndex, attr);

        *outValueArray = &temp;
        *length        = 1;
    }

    return set_error(p_data->error_handle, errorcode);
}

Reviewing this section of code from swmm solver, I think float temp should be float* temp instead because outValueArray is a double pointer.

@michaeltryby @cbuahin

This error is not caught because there isn't an unit test for get_system_attribute

@jennwuu jennwuu added the bug Something isn't working label Mar 6, 2021
@jennwuu jennwuu self-assigned this Mar 6, 2021
@michaeltryby
Copy link
Contributor

michaeltryby commented Mar 6, 2021

So this is actually a bug in the c library that causes Python to crash completely. Good catch!

@jennwuu
Copy link
Contributor Author

jennwuu commented Mar 6, 2021

yeah! I found it when i was extending output functionality in pyswmm

@cbuahin
Copy link

cbuahin commented Mar 7, 2021

I will fix it in my PR.

@cbuahin cbuahin self-assigned this Mar 9, 2021
@cbuahin cbuahin closed this as completed Mar 9, 2021
@cbuahin cbuahin reopened this Mar 9, 2021
@cbuahin
Copy link

cbuahin commented Mar 9, 2021

Addressed through pyswmm/Stormwater-Management-Model#322

@cbuahin cbuahin closed this as completed Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants