Skip to content

bridgev2/userlogin: copy the remote profile when filling bridge state#468

Closed
slice wants to merge 1 commit intomainfrom
skip/jj-smlqwxnzpypm
Closed

bridgev2/userlogin: copy the remote profile when filling bridge state#468
slice wants to merge 1 commit intomainfrom
skip/jj-smlqwxnzpypm

Conversation

@slice
Copy link

@slice slice commented Mar 7, 2026

Here's the relevant line:

state.RemoteProfile = &ul.RemoteProfile

By pointing into ul.RemoteProfile directly, the "pending" BridgeState will always point to the "latest" RemoteProfile, which leads the RemoteProfile comparison in ShouldDeduplicate to always think that the RemoteProfile hasn't changed:

func (pong *BridgeState) ShouldDeduplicate(newPong *BridgeState) bool {
return pong != nil &&
pong.StateEvent == newPong.StateEvent &&
pong.RemoteName == newPong.RemoteName &&
pong.UserAction == newPong.UserAction &&
ptr.Val(pong.RemoteProfile) == ptr.Val(newPong.RemoteProfile) &&

I think it's always going to dereference the same two pointers; i.e. it does *ul.RemoteProfile == *ul.RemoteProfile which would always be true.

We can make a copy instead, which will do a shallow snapshot of sorts:

	profileCopy := ul.RemoteProfile
	state.RemoteProfile = &profileCopy

It wouldn't be resilient to in-place AvatarFile mutations that don't take care to replace the entire value, but that seems okay?

Pointing into ul.RemoteProfile directly means that the RemoteProfile in
the pending BridgeState will always point to the "latest" RemoteProfile,
which leads the RemoteProfile comparison in ShouldDeduplicate to always
think that the RemoteProfile hasn't changed. It's always going to
dereference the same two pointers.
@slice slice requested a review from tulir March 7, 2026 05:32
state.RemoteName = ul.RemoteName
state.RemoteProfile = &ul.RemoteProfile
profileCopy := ul.RemoteProfile
state.RemoteProfile = &profileCopy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to just make BridgeState.RemoteProfile a non-pointer

@tulir tulir closed this in b42ac0e Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants