Skip to content

Bug: fluid.bufstats~ can crash when mixing threads #441

@rconstanzo

Description

@rconstanzo

Please tell us what you were doing! You can include code and files by drag and dropping them into the text area.

It seems that fluid.bufstats~ can insta-crash when it is getting messages from mixed threads, specifically receiving weights in it's right-most inlet in the high-priority thread, while the object is in @blocking 1 and then also receiving buffers upstream from the high-priority thread.

So I think the steps are:

  1. have fluid.bufstats~ @blocking 1
  2. send weights buffer to right inlet from high-priority thread
  3. send buffer into left inlet from high-priority thread

Sometimes this gives an Invalid weights error message (as mentioned below) but other times it will just crash, presumably when read/writing from unsafe memory.

This is happening in the patch outlined in this thread:
https://discourse.flucoma.org/t/creating-a-filter-from-spectral-moments-fluid-spectralshape/

Specifically this version of the patch:
https://discourse.flucoma.org/uploads/short-url/nkoDHX3alGOt8e2sudrKHQsmq3J.zip

The offending abstraction is dk.spectralshapeframe which has three instances of fluid.stats~ in it, and only one of which was having it's @blocking mode updated automatically (I missed the connection when building the patch).

If you run the patch for any amount of time you will see the error messages, and eventually a crash.

Here's a crash report:

bufstats crash.zip

What was the expected result?

Complaining about threading, which it did do as well:

fluid.bufstats~: Invalid weights

But sometimes it would not complain and instead crash.

What was the actual result?

An insta-crash.

What operating system were you using?

Mac

Operating system version

macOS 15.2

FluCoMa Version

1.0.8+sha.0a9327e.core.sha.7dfcc220

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions