Segmentation Fault when creating local magnetic field!

Hi,

I have been trying to modify exampleB1 to include a localised magnetic field, but I have run into a segmentation fault error which I don’t understand. The code compiles with no errors, but when I run it I get this segmentation fault.

I have copied sections of the code from example f03 and pasted them into the ConstructSDandField function in the B1DetectorConstrunction class.

The logical volume containing the field is a cylinder. Here is a snippet from the ConstructSDandField function:

void B1DetectorConstruction::ConstructSDandField()
{
 
  G4UniformMagField* fLocalMagneticField = new G4UniformMagField(G4ThreeVector(3.3*tesla,
                                                            0.0, // 0.5*tesla,
                                                            0.0));

  G4Mag_UsualEqRhs* fLocalEquation = new G4Mag_UsualEqRhs(fLocalMagneticField);

  G4double fMinStep     = 0.25*um ; // minimal step of 1 mm is default

  G4FieldManager* fLocalFieldManager = new G4FieldManager();
 

  G4cout<<"F03FieldSetup::UpdateField> The minimal step is equal to "
        << fMinStep/mm <<" mm"<<G4endl;
  G4cout<<"                            Stepper Type chosen = " //<< fStepperType
        << G4endl;

  // 2. Create the steppers ( Note: this also deletes the previous ones. )

  G4MagIntegratorStepper* fLocalStepper= nullptr;
  fLocalStepper = new G4ClassicalRK4( fLocalEquation );
  G4cout<<"G4ClassicalRK4 (default) is called"<<G4endl;


  // 3. Create the chord finder(s)
  G4ChordFinder* fLocalChordFinder = new G4ChordFinder(fLocalMagneticField,
                                        fMinStep,fLocalStepper);

  fLocalFieldManager->SetChordFinder(fLocalChordFinder);

  // 4. Ensure that the field is updated (in Field manager & equation)

  fLocalFieldManager->SetDetectorField(fLocalMagneticField);
  G4bool allLocal = true;

//Logical volume containing the field
  fFieldContainer->SetFieldManager(fLocalFieldManager,
                                  allLocal );

  G4cout<< "End of COnstructSDandField"<<G4endl;
}

This is my output

Any feedback on what might be causing this segmentation fault error would be greatly appreciated.

Thank you very much!

Cheers,
Luana