I'm trying to read and write to a binary file, it mostly works however
upon returning 0 in main ill get munmap_chunk(): invalid pointer: error
ill get a memory dump and a stack trace when the program closes
https://i.stack.imgur.com/UaCtk.jpg
here is a screenshot of the memory dump and stack trace, I don't know how to read this
#include <fstream>
#include <iostream>
using namespace std; 
struct player{
  string name;
};
   bool WriteTest(player playerData){
  // Create our objects.
  fstream filestream;
  //attempt to open file and then read first player
  filestream.open ("file.bin", ios::binary | ios::out);
  filestream.write(reinterpret_cast <char *> (&playerData), 
sizeof(playerData));
       if(filestream.fail()){
    //create file if there is no file
    cout << "write open failed" << endl;
    filestream.close();
    return false;
  }
    filestream.close();
        cout << "write sucsess" << endl;
          return true;
}
player ReadTest(){
  player playerData;
  // Create our objects.
  fstream filestream;
  //attempt to open file and then read first player
  filestream.open ("file.bin", ios::binary | ios::in);
  filestream.read(reinterpret_cast <char *> (&playerData), 
sizeof(playerData));
  if(filestream.fail()){
    //create file if there is no file
    cout << "read open failed" << endl;
    filestream.close();
    return playerData;
  }
  filestream.close();
  cout << "read sucsess" << endl;
  return playerData;
}
void displayPlayerData(player playerData){
  cout << " Name :" << playerData.name << endl;
}
int main(){
  player source;
  source.name = "bap";
  displayPlayerData(source);
  WriteTest(source);
 getchar();
  player playerData = ReadTest();
  displayPlayerData(playerData);
  return 0;
}