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

Analyser: Not holding onto references #1183

Closed
hsorby opened this issue Oct 5, 2023 · 4 comments · Fixed by #1185
Closed

Analyser: Not holding onto references #1183

hsorby opened this issue Oct 5, 2023 · 4 comments · Fixed by #1185
Assignees
Labels

Comments

@hsorby
Copy link
Contributor

hsorby commented Oct 5, 2023

When analysing a model the analyser does not hold onto object references that it later needs when generating code. This results in generated code that cannot be simulated.

@agarny
Copy link
Contributor

agarny commented Oct 5, 2023

No idea what you mean by this.

@hsorby
Copy link
Contributor Author

hsorby commented Oct 5, 2023

I'll write a test to show the problem.

@hsorby
Copy link
Contributor Author

hsorby commented Oct 5, 2023

Here is a test that will cause a segfault when trying to generate the implement code (implementationCode) :


TEST(Generator, modelOutOfScope)
{

    auto analyser = libcellml::Analyser::create();
    {
        auto parser = libcellml::Parser::create();
        auto model = parser->parseModel(fileContents("generator/ode_multiple_dependent_odes/model.cellml"));

        EXPECT_EQ(size_t(0), parser->issueCount());

        analyser->analyseModel(model);
    }

    EXPECT_EQ(size_t(0), analyser->errorCount());

    auto analyserModel = analyser->model();
    auto generator = libcellml::Generator::create();

    generator->setModel(analyserModel);

    auto profile = libcellml::GeneratorProfile::create(libcellml::GeneratorProfile::Profile::PYTHON);

    generator->setProfile(profile);

    EXPECT_EQ(fileContents("generator/ode_multiple_dependent_odes/model.py"), generator->implementationCode());
}

@agarny agarny self-assigned this Oct 5, 2023
@agarny agarny added the Analyser label Oct 5, 2023
@agarny
Copy link
Contributor

agarny commented Oct 5, 2023

Thanks, I am looking into it.

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

Successfully merging a pull request may close this issue.

2 participants