Skip to content

VoxelSource may cause potential double free in MT #1032

@tontyoutoure

Description

@tontyoutoure

At GateVoxelSource.cpp:45

  ll.fSPS->SetPosGenerator(fVoxelPositionGenerator);

which effectively does:

void GateSingleParticleSource::SetPosGenerator(GateSPSPosDistribution *pg) {
  fPositionGenerator = pg;
  ...
}

and in GateSingleParticleSource's destructor there is

delete fPositionGenerator;

So if the GateSingleParticleSource's destructor is called in worker thread (luckily or not, it isn't right now), a double free will occur. Solution is of course putting fVoxelPositionGenerator into a G4Cache. Of course there is also a bit of memory leak here, but I think that's not a very big deal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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