Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: fix a seg while t_continue with nats module #3396

Closed
wants to merge 1 commit into from

Conversation

seven1240
Copy link
Contributor

@seven1240 seven1240 commented Mar 21, 2023

Pre-Submission Checklist

  • Commit message has the format required by CONTRIBUTING guide
  • Commits are split per component (core, individual modules, libs, utils, ...)
  • Each component has a single commit (if not, squash them into one commit)
  • No commits to README files for modules (changes must be done to docbook files
    in doc/ subfolder, the README file is autogenerated)

Type Of Change

  • Small bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds new functionality)
  • Breaking change (fix or feature that would change existing functionality)

Checklist:

  • PR should be backported to stable branches
  • Tested changes locally
  • Related to issue #XXXX (replace XXXX with an open issue number)

Description

segfault

#0  0x0000ffffb9934840 in cfg_update_local (no_cbs=0) at ../../core/cfg/cfg_struct.h:366
366			cfg_child_cb = cfg_child_cb->next;
(gdb) print cfg_child_cb
$1 = (cfg_child_cb_t *) 0x0

example lua:

function ksr_route_nats()
	KSR.tm.t_newtran()
	local tindex = KSR.pv.gete("$T(id_index)")
	local tlabel = KSR.pv.gete("$T(id_label)")
	KSR.tmx.t_suspend()

	local req = {
		jsonrpc = "2.0", method = "route",
		id = tindex .. ':' .. tlabel,
		params = {
			from = KSR.pv.gete("$fu"),
			to = KSR.pv.gete("$tu"),
		}
	}
	local rpc = cjson.encode(req)
	KSR.info("rpc: " .. rpc .. "\n")
	KSR.nats.publish("cn.xswitch.ctrl.route", rpc)
	KSR.x.exit();
end

function handle_nats_response(data)
	msg = cjson.decode(data)
	if (not msg) or (not msg.id) then return end
	KSR.info("========= msg.id: " .. msg.id .. "\n")

	if not msg.result then
		KSR.error("response has no result\n")
		return
	end

	tindex, tlabel = msg.id:match("(.+):(.+)")
	if tindex and tlabel then
		KSR.pv.sets('$var(nats_response)', data)
		KSR.tmx.t_continue(tindex, tlabel, 'ksr_nats_continue')
	end
end

I'm not sure if it's the proper fix, but this pr fixed the seg. Thanks.

@henningw
Copy link
Contributor

Thanks for the PR. The change looks sensible to me, maybe it make sense to also log an error message. Interesting also why there is no callback pointer set in this situation. @eschmidbauer any comments regarding the patch as well?

@henningw
Copy link
Contributor

Probably related to issue #3395

@eschmidbauer
Copy link
Contributor

This fix looks okay to me but it's beyond the scope of the NATs module. And I'm wondering if this can be fixed in the NATS module instead of the core. The change you made here is probably called from nats in cfg_update. I wonder if @miconda has any insight

@henningw
Copy link
Contributor

You are right, its probably should be fixed in the NATS module instead of the core.

@seven1240
Copy link
Contributor Author

ffbb6ad fixed this one. should I add some warning log or close this?

@miconda
Copy link
Member

miconda commented Mar 30, 2023

Closing this one.

@seven1240: if you want to add some extra logging, make a new PR.

@miconda miconda closed this Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants