Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Has anybody used enable-float lately? #287

Closed
schnitzeltony opened this issue Nov 22, 2017 · 9 comments
Closed

Has anybody used enable-float lately? #287

schnitzeltony opened this issue Nov 22, 2017 · 9 comments

Comments

@schnitzeltony
Copy link

Hi,

First what happened:
I have the following setup on RaspberryPi3: qtractor -> fluidsynth-dssi (slightly reworked: configurable to make use of synth.cpu-cores) -> fluidsynth. A few weeks ago I updated fluidsynth 1.1.6 -> 1.1.8. With this update the build system was changed from autotools to cmake. I did not notice that the default is different for enable-float:

  • autotools build preferred float
  • cmake build prefers double

After discovering this, I changed to enable-float and run now into very strange errors:
In the setup phase fluidsynth-dssi allocates memory by calloc (see https://github.com/schnitzeltony/fluidsynth-dssi/blob/030273ab3b9c167a5b237bdabb8c59f93f1e68f7/src/fluidsynth-dssi.c#L343). This works fine when using double for fluidsysnth but when using float, it seems to return NULL. I say 'seems' because I debugged and stepped into calloc: After doing allocation, calloc returns with memset which should return memory pointer because it is feeded with plausible values. Stepping into memset was not helpful because it uses asm code.
From my experience these kind of 'impossible' errors happen in case of buffer overflow.

To get more information I switched back to fluidsynth 1.1.6 using autotools / floats: Works fine again.

What I don't understand: Until the position the error happens there are not many calls into fluidsynth (see the lines before calloc):

  • new_fluid_settings
  • fluid_settings_getint
    So what has changed between 1.1.6 and 1.1.8 causing this? Suggestions welcome...
@derselbst
Copy link
Member

derselbst commented Nov 22, 2017

I did not notice that the default is different for enable-float.

Me neither, but you are correct.

This works fine when using double for fluidsysnth

Which build? fluidsynth 1.1.6 with autotools or 1.1.8 with cmake?

So what has changed between 1.1.6 and 1.1.8 causing this?

Nothing relevant that I'm currently aware of. The synth has changed a little, but it seems you dont even get there. Will try a float build myself and do some tests within the next days. In the meantime, here's the diff. Keep looking for WITH_FLOAT.

@mawe42
Copy link
Member

mawe42 commented Nov 22, 2017

I've been building FluidSynth with enable-floats quite often over the last few weeks and didn't notice any problems. Are you really using the 1.1.8 release, or the current master (which also reports as 1.1.8 I think?).

@schnitzeltony
Copy link
Author

schnitzeltony commented Nov 22, 2017

Thanks for quick responses.

@derselbst

Which build? fluidsynth 1.1.6 with autotools or 1.1.8 with cmake?

1.1.8 + double OK / 1.1.8 + float NOK / 1.1.6 + float from old sourceforge tarball build with autotools OK

@mawe42
I build from git 12e7afe which is 1.1.8 release.

I did already check for some suspicious code in git but did not find some. So this is the situation as I see it:
I have a very strange symptom which does not occur on elder version of fluidsynth. This is a classic use-case for git bisect. Although this is lots of efforts - I will try that the next days - hope it leads to some enlightenment...

@mawe42
Copy link
Member

mawe42 commented Nov 22, 2017

Maybe start with trying 1.1.6 + cmake + floats. Or have you tried that already?

@schnitzeltony
Copy link
Author

Maybe start with trying 1.1.6 + cmake + floats. Or have you tried that already?
Thought the same after I wrote previous comment :)

@derselbst
Copy link
Member

@schnitzeltony Pls make sure you insert a blank line between the quote and your comment. It drives me crazy otherwise.

@schnitzeltony
Copy link
Author

I rebuilt my image completely and the issue is gone! So everybody I caused wasting time on this: Sorry & Thanks a lot!

@derselbst
Copy link
Member

Dont be sorry, I actually just fixed a buffer overrun in a13cb63. At least I hope so, because even after reverting the fix, the segfault is gone O_o

@schnitzeltony
Copy link
Author

The embarrassing part: After I wrote my recent 'Everything is fine - sorry' comment, I found out that I did not have floats activated properly: For some reason I had 'enable-float' instead of 'enable-floats' in my build. After fixing this I saw segfaults again, my ears turned red and I was wondering how to explain this here...

And now the fun part: After including the patch you just created it works - and I get an idea what happened: fluid_synth_nwrite_float is called by worker thread. It overwrites the variables I was using magically in the 'background'.
@derselbst you are my today's hero: Thanks a lot!!!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants