Csound Csound-dev Csound-tekno Search About

[Csnd] Csound 6 issues partly resolved: add -mstackrealign to CFLAGS and CXXFLAGS

Date2013-08-23 01:50
FromMichael Gogins
Subject[Csnd] Csound 6 issues partly resolved: add -mstackrealign to CFLAGS and CXXFLAGS
AttachmentsNone  None  
I have discovered part of the reason for problems I described earlier with the Windows build of Csound 6. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48659 for some time now causes memory misalignment in stack frames and thus segfaults when OpenMP and SSE are used together, as we often do in Csound.

There is a workaround. All code that uses both SSE and OpenMP should be compiled with the -mstackrealign option. For our purposes, that means all code that is part of Csound and all code that is used by Csound. Reports are that there is no performance penalty.

After rebuilding Csound and CsoundQt with MinGW 4.8.1 32 bits dwarf2 exception handling Posix threads, just as I have been doing, but with -mstackrealign, the CsoundPerformanceThread unit test passes, and CsoundQt runs and performs Csound pieces.

I also ran CppCheck on the Csound source code and fixed a number of errors and warnings.

The memory allocation error I described earlier still occurs.

The problem with CsoundQt not running audio properly a second time still occurs.

The problem with the Java examples not running still occurs.

Nevertheless, I am replacing the Csound installer on SourceForge with this new build.

In the future, if debugging does not soon reveal the cause of a bug, you can be sure I am heading straight for the compiler bug trackers.

The next minor release of Csound will include all third party code compiled with the same options.

Regards,
Mike


===========================
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com

Date2013-08-23 02:13
FromSteven Yi
SubjectRe: [Csnd] Csound 6 issues partly resolved: add -mstackrealign to
Wow, great find!  Sounds like a definite step forward.  Thanks very
much for all your work on this!

On Thu, Aug 22, 2013 at 8:50 PM, Michael Gogins
 wrote:
> I have discovered part of the reason for problems I described earlier with
> the Windows build of Csound 6.
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48659 for some time now causes
> memory misalignment in stack frames and thus segfaults when OpenMP and SSE
> are used together, as we often do in Csound.
>
> There is a workaround. All code that uses both SSE and OpenMP should be
> compiled with the -mstackrealign option. For our purposes, that means all
> code that is part of Csound and all code that is used by Csound. Reports are
> that there is no performance penalty.
>
> After rebuilding Csound and CsoundQt with MinGW 4.8.1 32 bits dwarf2
> exception handling Posix threads, just as I have been doing, but with
> -mstackrealign, the CsoundPerformanceThread unit test passes, and CsoundQt
> runs and performs Csound pieces.
>
> I also ran CppCheck on the Csound source code and fixed a number of errors
> and warnings.
>
> The memory allocation error I described earlier still occurs.
>
> The problem with CsoundQt not running audio properly a second time still
> occurs.
>
> The problem with the Java examples not running still occurs.
>
> Nevertheless, I am replacing the Csound installer on SourceForge with this
> new build.
>
> In the future, if debugging does not soon reveal the cause of a bug, you can
> be sure I am heading straight for the compiler bug trackers.
>
> The next minor release of Csound will include all third party code compiled
> with the same options.
>
> Regards,
> Mike
>
>
> ===========================
> Michael Gogins
> Irreducible Productions
> http://michaelgogins.tumblr.com
> Michael dot Gogins at gmail dot com