Three issues identified.
1. Crash due to state missing
    Route is matched by the match condition and state is added before adding to WorkQueue.
    Route Entry gets deleted and delete request is added to Work Queue
    Route entry gets reused and Add request is now added to WorkQueue and subsequently the route entry gets deleted.
    When the work queue is processed with above 3 events, we can delete the MatchsTate with route still present in the WorkQueue.
2. Crash due to early unregister of DBClient even with DBState pending.
    When service chain config is deleted, the Unregister of the condition is done after Walk is completed. This event can occur before all MatchSTates are removed from the route. Due to this RemoveMAtchState function can possibly get called after the client is unregistered.
3. Concurrency issue in setting/accessing “stopped” flag of service chain object. It was set in the WalkDone function(in db:DBTable task) and flag is checked in Match function(Called from Notify in db:DBTable task). Since these two can be running in parallel (From different partition task), we can enqueue requests/set-state even after stopping the service chain. Which was the root cause calling unregister with MatchState set.

Solution:
To overcome the above issues,  I have made following fixes
1. Maintain a ref count on MatchState. Refcount is taken when the route is added to the work queue. RemoveMatchSTate is only called when refcount goes to zero. IF the route entry gets reused, recycle the state by resetting the delete flag
2. Track the number of MatchSTate added on a MatchCondition. UnregisterCondition is called only after all MatchStates are deleted.
3. Removed the "stopped" flag as the fix handles entries after the service chain is stopped.
4. added test cases which recreates the crashes. (One unregister with state pending and Missing Match state while handling add request).
Merge pull request #511 from Juniper/2397

Fix for 2397