Code crashing Unity

Here is the code that crashes unity, I’m not sure what is wrong.

void Update () {
		
		if(pb1){
			ShowB1Ghost();	
		}
	
	}
	
	void ShowB1Ghost(){
		
		b1Ghost.SetActive(true);
		
		RaycastHit hit;
		if (Physics.Raycast	(cam.ScreenPointToRay (Input.mousePosition), out hit, Mathf.Infinity, Mask)) {
			
			b1Ghost.transform.position = hit.point;
			
			if(Input.GetMouseButton(0)){
				
				pb1 = false;
				b1Ghost.SetActive(false);
								
				Transform building = PoolManager.Pools["Bases"].Spawn(SpawnB1.transform, b1Ghost.transform.position, b1Ghost.transform.rotation);
				MeshRenderer[] renderers = (MeshRenderer[]) building.GetComponentsInChildren<MeshRenderer>();
				GameObject[] objsToAdd = new GameObject[renderers.Length];
				
				
				for (int r = 0; r < renderers.Length; r++){
				    objsToAdd[r] = renderers[r].gameObject;
				}
				
				skinnedMeshBakerGood.AddDeleteGameObjects(objsToAdd,null);
				skinnedMeshBakerGood.Apply();
				
			}
		}
	}

Does it crash no matter what or only when you click on something?

It’s only when I execute the click if(Input.GetMouseButton(0)){

comment out all lines in the block and try if it works. then uncomment one line after the other try each time and see at which line it crashes. then verify all things in that line (fe with debug.log).

This is a shot in the dark:
If one of the methods at line 32 or 33 internally use MarkDynamic on the mesh and you are using DX11 for the graphics, it will crash Unity.

Yeah thanks guys narrowed it down to A* pathfinding GraphUpdate on my building.

Working to get this fixed now!

Whats the error? Does b1Ghost exist?