[Bug] print wrong node information in poll.go #825

Closed
opened 2025-12-29 02:24:28 +01:00 by adam · 2 comments
Owner

Originally created by @PatrickHuang888 on GitHub (Oct 9, 2024).

Is this a support request?

  • This is not a support request

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

func (h *Headscale) newMapSession(
	ctx context.Context,
	req tailcfg.MapRequest,
	w http.ResponseWriter,
	node *types.Node,
) *mapSession {

// here passed node to print functions in init
	warnf, infof, tracef, errf := logPollFunc(req, node)

return &mapSession{

		node:   node,

		// Loggers
		warnf:  warnf,
		infof:  infof,
		tracef: tracef,
		errf:   errf,
	}
...

func (m *mapSession) serveLongPoll() {
    for {
        case update, ok := <-m.ch:

            // later override the node reference
            m.node, err = m.h.db.GetNodeByID(m.node.ID)

         switch update.Type {
			case types.StateFullUpdate:
                      // actually print old node not the m.node
				m.tracef("Sending Full MapResponse")
    }
}

Expected Behavior

maybe tracef reference to pointer of m.node ? not quit sure

func logPollFunc(
	mapRequest tailcfg.MapRequest,
	node **types.Node,
)
	mapSession:= &mapSession{
		node:   node,
	}
	warnf, infof, tracef, errf := logPollFunc(req, &mapSession.node)
	mapSession.warnf = warnf
	mapSession.infof = infof
	mapSession.tracef = tracef
	mapSession.errf = errf
	return mapSession

and is there any memory leak as tracef reference a unused node?

Steps To Reproduce

just read the code

Environment

- OS:
ubuntu
- Headscale version:
branch main

Runtime environment

  • Headscale is behind a (reverse) proxy
  • Headscale runs in a container

Anything else?

No response

Originally created by @PatrickHuang888 on GitHub (Oct 9, 2024). ### Is this a support request? - [X] This is not a support request ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current Behavior ```go func (h *Headscale) newMapSession( ctx context.Context, req tailcfg.MapRequest, w http.ResponseWriter, node *types.Node, ) *mapSession { // here passed node to print functions in init warnf, infof, tracef, errf := logPollFunc(req, node) return &mapSession{ node: node, // Loggers warnf: warnf, infof: infof, tracef: tracef, errf: errf, } ... func (m *mapSession) serveLongPoll() { for { case update, ok := <-m.ch: // later override the node reference m.node, err = m.h.db.GetNodeByID(m.node.ID) switch update.Type { case types.StateFullUpdate: // actually print old node not the m.node m.tracef("Sending Full MapResponse") } } ``` ### Expected Behavior maybe tracef reference to pointer of m.node ? not quit sure ```go func logPollFunc( mapRequest tailcfg.MapRequest, node **types.Node, ) mapSession:= &mapSession{ node: node, } warnf, infof, tracef, errf := logPollFunc(req, &mapSession.node) mapSession.warnf = warnf mapSession.infof = infof mapSession.tracef = tracef mapSession.errf = errf return mapSession ``` and is there any memory leak as tracef reference a unused node? ### Steps To Reproduce just read the code ### Environment ```markdown - OS: ubuntu - Headscale version: branch main ``` ### Runtime environment - [ ] Headscale is behind a (reverse) proxy - [ ] Headscale runs in a container ### Anything else? _No response_
adam added the stalebug labels 2025-12-29 02:24:28 +01:00
adam closed this issue 2025-12-29 02:24:28 +01:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 8, 2025):

This issue is stale because it has been open for 90 days with no activity.

@github-actions[bot] commented on GitHub (Jan 8, 2025): This issue is stale because it has been open for 90 days with no activity.
Author
Owner

@github-actions[bot] commented on GitHub (Jan 16, 2025):

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions[bot] commented on GitHub (Jan 16, 2025): This issue was closed because it has been inactive for 14 days since being marked as stale.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#825