Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • dynare dynare
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 108
    • Issues 108
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 7
    • Merge requests 7
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Dynare
  • dynaredynare
  • Issues
  • #1820
Closed
Open
Created Oct 13, 2021 by Sébastien Villemot@sebastienOwner

Invalid memory accesses in local_state_space_iteration_2 when there are more shocks than states

In local_state_space_iteration_2, in function ss2Iteration, the block that computes ghx·yhat+ghu·u reads as follows:

          for (int column = 0, column_ = 0; column < q; column++, column_ += m)
            {
              int i1 = variable+column_;
              int i2 = column+particle__;
              int i3 = column+particle___;
              y[variable_] += ghx[i1]*yhat[i2];
              y[variable_] += ghu[i1]*epsilon[i3];
            }
          for (int column = q, column_ = q*m; column < n; column++, column_ += m)
            y[variable_] += ghx[variable+column_]*yhat[column+particle__];

This code makes the implicit assumption that q⩽n, i.e. that the number of shocks is less than or equal to the number of states. If q>n, it will try to read invalid memory references in ghx and yhat, and it will either crash or return dummy results.

The same problem is present in the ss2Iteration_pruning function.

The fix is simply to reorganize the loops, with one loop that only deals with the states and another one that deals with shocks.

@stepan-a If you agree with this diagnostic, I will take care of fixing it.

Assignee
Assign to
Time tracking