Symptoms
The merge agent fails with the following error message:

The remote procedure call failed and did not executeThe task reports the preceding remote procedure call (RPC) failure in its history, which can be misleading because there are not any other connectivity problems. The merge agent runs into a handled exception with the following stack, as seen in the replication exception log file:

The Exception Stack Dump follows:
ntdll77f67546RtlpWaitForCriticalSection
ntdll41d70871RtlEnterCriticalSection
replrec41d68839CReconcilerHistory::AddMessage
replrec41d666c8CDatabaseReconciler::LogProgressMessage
replrec41d66362CDatabaseReconciler::ProcTombstones
replrec41d65449CDatabaseReconciler::MoveChangesToDest
replrec00403819CDatabaseReconciler::Reconcile
replmerg004038e2CReconcilerTask::Reconcile
replmerg00407af8AgentRun
replmerg08ec83ecAgentMain

Resolution
The RPC failed message is the result of a exception with the merge agent. Replmerg.exe fails while inserting generation history, generating an exception when completely filling the allocated memory buffer. This causes an out of space situation and the required null termination character cannot be added, subsequently causing the access violation.