pierreguillot / Camomile

An audio plugin with Pure Data embedded that allows to load and to control patches
GNU General Public License v3.0
892 stars 62 forks source link

textfile / text define : reading attempt of non-existing file makes plugin crash #239

Closed jyg closed 3 years ago

jyg commented 3 years ago
  1. when sending a message [read ...( to [textfile] or [text define ...], plugin crashes if the specified file doesn't exist.

  2. tested on linux 18.04-5 LTS with latest reaper 64 and camomille vst3 v1.0.8 beta (using PdStalFx plugin to load the patch)

  3. Open the attached patch. test_textfile.pd.zip

if you click on the second row of bngs, you load the existing test_textfile.pd into [textfile] and [text define] objects if you click on the first row, you are trying to load an unexisting file and the plugin crashes image

pierreguillot commented 3 years ago

I can reproduce the bug on Linux (not MacOS and I didn't test on Windows yet). The problem also occurs using Ardour.

jyg commented 3 years ago

Here is an abstraction to insert before [textfile] / [text define] inlet in order to prevent crash. image #239-workaround.pd.zip

pierreguillot commented 3 years ago

It seems that this call of error() generates a crash. The only way I managed to fix the problem is to remove this line. I couldn't find the exact cause of the crash so far, I tried to remove all the content of the error() function so the function doesn't do anything but it still crashes. It seems that the address of the function is not valid...

pierreguillot commented 3 years ago

Perhaps it gets confused with this function?

jyg commented 3 years ago

It seems that this call of error() generates a crash.

Yes, and indeed soundfiler_read uses pd_error() instead of error() and doesn't crash.

Perhaps it gets confused with this function?

You mean it should be linked instead with EXTERN void error(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2); as defined in m_pd.h ?

pierreguillot commented 3 years ago

You mean it should be linked instead with EXTERN void error(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2); as defined in m_pd.h ?

Yes, this is my assumption. But for an obscure reason, it links with another function named error()...

jyg commented 3 years ago

It shoud be related to Juce framework ? Another potential crasher : g_clone.c that contains an error() call. Put [clone print 4] in a patch and it generates the error clone: can't clone 'print' because it's not an abstraction . This crashes the plugin.

pierreguillot commented 3 years ago

It shoud be related to Juce framework ?

I don't think but I'm not sure. I sent a mail on the pd-dev list to get some help from libpd and linux gurus

Another potential crasher : g_clone.c that contains an error() call.

In fact, all the uses of the error() function cause a crash. And the function is used many times... :(

pierreguillot commented 3 years ago

I did a dirty hack but can you confirm that the bug is fixed with these binaries?

jyg commented 3 years ago

yes it works ! Thanks

pierreguillot commented 3 years ago

@jyg I found a good fix. Can you test the Linux artifacts of this commit? Thank you!

jyg commented 3 years ago

I tested camomile.so and camomileFx.so . It works perfectly, doesn't crash anymore. Thanks !