Skip to content

Memory Corruption causes crash when Chemistry is enabled #166

@paspro

Description

@paspro

With respect to the master version of code_saturne there is a bug in file /src/cogz/cs_combustion_read_data.cpp, line 1067 which has the following loop:

      // Stoichiometry in global reaction species
      for (int ir= 0; ir < n_gas_species; ir++) {
        for (int igg = 0; igg < n_gas_species; igg++) {
          stoeg[ir][igg] = 0.;
          for (int ige = 0; ige < ngase; ige++) {
            stoeg[ir][igg] += cm->compog[igg][ige]*nreact[igg];
          }
        }

The "ir" counter should iterate through the number of reactions and not the number of gas species. This causes memory overwriting which, at least on my computer, caused the corruption of some other neighbouring data structure causing a crash. The correct code is the following:

      // Stoichiometry in global reaction species
      for (int ir= 0; ir < cm->n_reactions; ir++) {
        for (int igg = 0; igg < n_gas_species; igg++) {
          stoeg[ir][igg] = 0.;
          for (int ige = 0; ige < ngase; ige++) {
            stoeg[ir][igg] += cm->compog[igg][ige]*nreact[igg];
          }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions