session: fix vpp exit abnormal due to application as a proxy server with ldp
Type: fix
The function of application_setup_proxy() be called when application run as a
proxy server, "app_wrk->first_segment_manager" be realloced in this function,
but variable of "sm" point original memory location.
@@ -874,7 +874,15 @@ vnet_application_attach (vnet_app_attach_args_t * a)
fs = segment_manager_get_segment_w_lock (sm, 0);
if (application_is_proxy (app))
+ {
application_setup_proxy (app);
+ /*
+ * I suspect the segment manager pool gets reallocated (because a new listener
+ * is added, and each listener has a segment manager) so sm becomes a dangling
+ * reference. That's why we need to re-grab sm.
+ */
+ sm = segment_manager_get (app_wrk->first_segment_manager);
+ }
ASSERT (vec_len (fs->ssvm.name) <= 128);
a->segment = &fs->ssvm;
