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

ParticleSystem2 has many bugs when use Multi-thread。 #480

Open
36yang opened this issue Nov 22, 2024 · 4 comments
Open

ParticleSystem2 has many bugs when use Multi-thread。 #480

36yang opened this issue Nov 22, 2024 · 4 comments
Assignees
Labels
bug Something isn't working Priority: High

Comments

@36yang
Copy link
Contributor

36yang commented Nov 22, 2024

System Information

  • Ogre Version: ❔ OgreNext 4.0 latest
  • Operating System / Platform: ❔ Windows11
  • RenderSystem: ❔ DX11
  • GPU: ❔ RTX4060

Detailled description

When I create a multi-threaded(4 thread) scene manager and use the particleSystem2 as Sample, waiting for 3-5 minutes will randomly encounter many problems, such as throwing multiple exceptions or encountering particles
Only one particle can be emitted at a time when the upper limit is reached, and there are actually no live particles.

Ogre.log

Callstack

Here is my screenshot:

QQ图片20241122104145

@darksylinc
Copy link
Member

Hi!

If I understood correctly, all I need to do is set the number of threads to 4 and wait a few minutes for the PFX2 Sample to crash?

I'm going to need a way to repro otherwise (e.g. by modifying the Sample to trigger the crash).

Cheers

@36yang
Copy link
Contributor Author

36yang commented Nov 22, 2024

Yes, I can reproduce it 100% like this。
GZ7BG6%BNC@6QKFCJ_4{I

@darksylinc darksylinc self-assigned this Nov 22, 2024
@darksylinc darksylinc added bug Something isn't working Priority: High labels Nov 22, 2024
@darksylinc
Copy link
Member

Thanks!

I was able to repro the problem.

Thread Sanitizer located the issue too.

ParticleSystemManager2::_updateParallel runs in two stages:

  1. Emit new particles
  2. Run emitters to all particles and tickParticles()

The problem is that the particles emitted in stage 1 by thread A may be in the middle of the range processed by stage 2 in thread B; thus the state of the particle becomes corrupt as A wants to reuse an inactive particle (to activate it) while B should be skipping that particle but seens it's suddenly active (because of A).

I'll need to think this through on how to fix it.

@36yang
Copy link
Contributor Author

36yang commented Nov 22, 2024

It's great to be able to find the problem. Multithreading is giving me a headache and I'm waiting for it to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Priority: High
Projects
None yet
Development

No branches or pull requests

2 participants