Skip to content

nil-pointer in collaborative recommending process #965

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

Open
ligustah opened this issue Apr 7, 2025 · 0 comments · May be fixed by #966
Open

nil-pointer in collaborative recommending process #965

ligustah opened this issue Apr 7, 2025 · 0 comments · May be fixed by #966
Labels
bug Something isn't working

Comments

@ligustah
Copy link
Contributor

ligustah commented Apr 7, 2025

Gorse version
Latest nightly

Describe the bug
I'm not seeing collaborative recommendations being created for most users, only a very small fraction appears to succeed.

I'm seeing workers crash a lot with this error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x1bb7c0a]

goroutine 1 [running]:
github.com/zhenghaoz/gorse/logics.(*MatrixFactorization).Search(0x0, {0xc026aa8dc0?, 0xc059c80f60?, 0x18?}, 0x1e37e00?)
	/src/logics/cf.go:58 +0x2a
github.com/zhenghaoz/gorse/worker.(*Worker).collaborativeRecommendHNSW(0xc000298900, 0x0, {0xc059c80f60, 0x18}, {0x24a9540, 0xc04d7b6580}, 0xc03bc40608)
	/src/worker/worker.go:867 +0x17c
github.com/zhenghaoz/gorse/worker.(*Worker).Recommend.func2(0x0, 0x1477)
	/src/worker/worker.go:620 +0xc9a
github.com/zhenghaoz/gorse/common/parallel.Parallel(0x4793, 0xc021f16810?, 0xc047c1a0a0)
	/src/common/parallel/parallel.go:40 +0xf7
github.com/zhenghaoz/gorse/worker.(*Worker).Recommend(0xc000298900, {0xc062c80000, 0x4793, 0x4955})
	/src/worker/worker.go:574 +0xbca
....

To Reproduce
I believe it to be a race condition, but not sure under which circumstances exactly it triggers.

  1. w.matrixFactorization is nil here:

    recommend, usedTime, err = w.collaborativeRecommendHNSW(w.matrixFactorization, userId, excludeSet, itemCache)

  2. It's set to nil here:

    w.matrixFactorization = nil

  3. It's supposed to be created here:

    if w.RankingModel != nil && !w.RankingModel.Invalid() && w.matrixFactorization == nil {

Whenever 2. occurs between 3. and 1. this error is going to be triggered. I believe there needs to be a mutex protecting it, or alternatively use atomic pointers and update both the model and matrixFactorization atomically.

@ligustah ligustah added the bug Something isn't working label Apr 7, 2025
@ligustah ligustah linked a pull request Apr 7, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant