stack smashing detected

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

stack smashing detected

Thomas Morley-2
Hi all,

the following code

\version "2.21.0"
{
  \override Slur.control-points = #'((1 . 0) (2 . 3) (3 . 4) (4 . 3) (5 . 0))
  b1( b)
}

stored in metaspline-tests-01.ly, returns:

GNU LilyPond 2.21.0
Processing `metaspline-tests-01.ly'
Parsing...
Interpreting music...
Preprocessing graphical objects...
Finding the ideal number of pages...
Fitting music on 1 page...
Drawing systems...*** stack smashing detected ***: <unknown> terminated
Aborted (core dumped)

Obviously more control-points than usual are provided.
Though I've never seen such a message.
Any insights?
gdb-output attached.


Background: I'm exploring whether it would be feasable to draw higher
order bezier-curves, splitting them in cubic ones.
I've already a basic stencil-procedure doing so. I'd like to call the
provided 'control-points from inside it and if 4 found use the default
stencil-procedure  otherwise use the other.

An image attached with a 7th order bezier, where I provide the
control-points directly to the stencil-procedure not going for the
'control-points grob-property.

I'm aware Urs already did some work in this regard, though his
approach was different, iirc.


Thanks,
  Harm

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel

7th-order-bezier.png (10K) Download Attachment
gdb-too-many-cps.log (25K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

David Kastrup
Thomas Morley <[hidden email]> writes:

> Hi all,
>
> the following code
>
> \version "2.21.0"
> {
>   \override Slur.control-points = #'((1 . 0) (2 . 3) (3 . 4) (4 . 3) (5 . 0))
>   b1( b)
> }
>
> stored in metaspline-tests-01.ly, returns:
>
> GNU LilyPond 2.21.0
> Processing `metaspline-tests-01.ly'
> Parsing...
> Interpreting music...
> Preprocessing graphical objects...
> Finding the ideal number of pages...
> Fitting music on 1 page...
> Drawing systems...*** stack smashing detected ***: <unknown> terminated
> Aborted (core dumped)
>
> Obviously more control-points than usual are provided.
> Though I've never seen such a message.
> Any insights?
> gdb-output attached.
>
>
> Background: I'm exploring whether it would be feasable to draw higher
> order bezier-curves, splitting them in cubic ones.

That's not overly useful: higher order bezier curves are higher-order
polynomials and tend to have quite less affinity to their control points
than cubic beziers have.  When splicing them together, the boundary
conditions prescribe more continuous derivatives than human drawing
would care for.  So usually your goals would be better served by
allowing _multiple_ cubic beziers in a row with suitable continuity of
derivatives (and thus some aspects of the control points) provided
automagically.  Metafont is an ingenious engine for specifying this sort
of thing, so studying it is likely a good idea.

I have an old copy of the Metafont Book flying around here that I
haven't touched in years.  I could send it to you if you want to get
ideas.  It's better than some PDF on a computer and, well, legal too.

With regard to the stack smashing: that indeed looks awful.  I'll take a
look at it.

--
David Kastrup

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

benko.pal
David Kastrup <[hidden email]> ezt írta (időpont: 2019. ápr. 25., Cs, 16:46):
>
> Thomas Morley <[hidden email]> writes:
>
> > Background: I'm exploring whether it would be feasible to draw higher
> > order bezier-curves, splitting them in cubic ones.

you can't split a Bezier curve into lower order ones, only approximate.

> So usually your goals would be better served by
> allowing _multiple_ cubic beziers in a row with suitable continuity of
> derivatives (and thus some aspects of the control points) provided
> automagically.

which is called B-splines.  is it possible to use (cubic) B-splines directly?

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

David Kastrup
Benkő Pál <[hidden email]> writes:

> David Kastrup <[hidden email]> ezt írta (időpont: 2019. ápr. 25., Cs, 16:46):
>>
>> Thomas Morley <[hidden email]> writes:
>>
>> > Background: I'm exploring whether it would be feasible to draw higher
>> > order bezier-curves, splitting them in cubic ones.
>
> you can't split a Bezier curve into lower order ones, only approximate.
>
>> So usually your goals would be better served by
>> allowing _multiple_ cubic beziers in a row with suitable continuity of
>> derivatives (and thus some aspects of the control points) provided
>> automagically.
>
> which is called B-splines.  is it possible to use (cubic) B-splines directly?

What's "directly"?  Where you can use multiple splines with control
points, by suitably calculating the control points, you can of course
use B-splines.

--
David Kastrup

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

Thomas Morley-2
In reply to this post by David Kastrup
Am Do., 25. Apr. 2019 um 16:45 Uhr schrieb David Kastrup <[hidden email]>:
>
> Thomas Morley <[hidden email]> writes:

> > Background: I'm exploring whether it would be feasable to draw higher
> > order bezier-curves, splitting them in cubic ones.
>
> That's not overly useful: higher order bezier curves are higher-order
> polynomials and tend to have quite less affinity to their control points
> than cubic beziers have.

Yeah, I noticed.

> When splicing them together, the boundary
> conditions prescribe more continuous derivatives than human drawing
> would care for.  So usually your goals would be better served by
> allowing _multiple_ cubic beziers in a row with suitable continuity of
> derivatives (and thus some aspects of the control points) provided
> automagically.  Metafont is an ingenious engine for specifying this sort
> of thing, so studying it is likely a good idea.
>
> I have an old copy of the Metafont Book flying around here that I
> haven't touched in years.  I could send it to you if you want to get
> ideas.  It's better than some PDF on a computer and, well, legal too.

This whole thing started as an attempt to increase my knowledge about
beziers in general.
I feel already having some success in better understanding beziers, consulting:
 - for all:
https://pomax.github.io/bezierinfo/
- A practical example of Catmull-Rom <-> Bezier conversion
https://stackoverflow.com/questions/30419726/simplify-high-order-bezier-curve
- Some guile code here:
guile-gnome/gtk/examples/metaspline.scm

Many thanks for the offer about the Metafont Book, I'll probably
(likely) come back to it.
For now I'll continue on the described route, looking how far I get.
At least I expect increasing knowledge of such curves...

Thanks,
  Harm

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

Thomas Morley-2
In reply to this post by benko.pal
'

Am Do., 25. Apr. 2019 um 17:21 Uhr schrieb Benkő Pál <[hidden email]>:
>
> David Kastrup <[hidden email]> ezt írta (időpont: 2019. ápr. 25., Cs, 16:46):
> >
> > Thomas Morley <[hidden email]> writes:
> >
> > > Background: I'm exploring whether it would be feasible to draw higher
> > > order bezier-curves, splitting them in cubic ones.
>
> you can't split a Bezier curve into lower order ones, only approximate.

Bad wording of mine, sorry.
I meant 'approximate'.

> > So usually your goals would be better served by
> > allowing _multiple_ cubic beziers in a row with suitable continuity of
> > derivatives (and thus some aspects of the control points) provided
> > automagically.
>
> which is called B-splines.  is it possible to use (cubic) B-splines directly?

B-splines are also mentioned in one of the linked sources, but
currently can't deal with them. I'll continue exploring ;)

Thanks,
  Harm

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

David Kastrup
Thomas Morley <[hidden email]> writes:

> '
>
> Am Do., 25. Apr. 2019 um 17:21 Uhr schrieb Benkő Pál <[hidden email]>:
>>
>> David Kastrup <[hidden email]> ezt írta (időpont: 2019. ápr. 25., Cs, 16:46):
>> >
>> > Thomas Morley <[hidden email]> writes:
>> >
>> > > Background: I'm exploring whether it would be feasible to draw higher
>> > > order bezier-curves, splitting them in cubic ones.
>>
>> you can't split a Bezier curve into lower order ones, only approximate.
>
> Bad wording of mine, sorry.
> I meant 'approximate'.
>
>> > So usually your goals would be better served by
>> > allowing _multiple_ cubic beziers in a row with suitable continuity of
>> > derivatives (and thus some aspects of the control points) provided
>> > automagically.
>>
>> which is called B-splines.  is it possible to use (cubic) B-splines directly?
>
> B-splines are also mentioned in one of the linked sources, but
> currently can't deal with them. I'll continue exploring ;)

It just means that you draw a number of Bezier curves through a number
of curve points maintaining as many continuous derivatives as your
Bezier degree can deliver per point and then filling the remaining
degrees of freedom at the end points with suitable boundary conditions.
Typical choices are "periodic", namely keeping all derivatives at the
end the same as at the start, or "natural", making the final derivatives
zero.  I may have some Bezier curve booklet as well but it's likely with
examples in BASIC and not necessarily all the math is correct.

--
David Kastrup

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

Karlin High
In reply to this post by Thomas Morley-2
On 4/25/2019 5:14 AM, Thomas Morley wrote:
> Background: I'm exploring whether it would be feasable to draw higher
> order bezier-curves, splitting them in cubic ones.

> I'm aware Urs already did some work in this regard, though his
> approach was different, iirc.

Threads from September 2016...

"Compound Slurs"
<https://lists.gnu.org/archive/html/lilypond-user/2016-09/msg00575.html>

"What to do with wanting a 4th order Bezier"
<https://lists.gnu.org/archive/html/lilypond-user/2016-09/msg00436.html>

Somewhere in there, I remember Urs Liska had LilyPond producing the
Sorabij Clavicembalisticum slur, as well as others that resembled my
5-year-old's work with Microsoft Paint.

Or was all of that the "different approaches" that are not aligned with
the efforts in this thread?
--
Karlin High
Missouri, USA

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

Thomas Morley-2
Am Do., 25. Apr. 2019 um 19:22 Uhr schrieb Karlin High <[hidden email]>:

>
> On 4/25/2019 5:14 AM, Thomas Morley wrote:
> > Background: I'm exploring whether it would be feasable to draw higher
> > order bezier-curves, splitting them in cubic ones.
>
> > I'm aware Urs already did some work in this regard, though his
> > approach was different, iirc.
>
> Threads from September 2016...
>
> "Compound Slurs"
> <https://lists.gnu.org/archive/html/lilypond-user/2016-09/msg00575.html>
>
> "What to do with wanting a 4th order Bezier"
> <https://lists.gnu.org/archive/html/lilypond-user/2016-09/msg00436.html>
>
> Somewhere in there, I remember Urs Liska had LilyPond producing the
> Sorabij Clavicembalisticum slur, as well as others that resembled my
> 5-year-old's work with Microsoft Paint.
>
> Or was all of that the "different approaches" that are not aligned with
> the efforts in this thread?

Hi Karlin,

this thread is about the 'stack smashing detected' message for overful
control-points. ;)

Ofcourse I highly appreciate any hint/comment about the underlying
work, which triggered the crash.
Thus many thinks for the links you posted.

Though I have a problem here:
I've found Urs' code here
https://github.com/openlilylib/snippets
in a subfolder.

So how to make it work?
git clone https://github.com/openlilylib/snippets.git
will give me the repository, but obviously a lot is missing.
What am I supposed to do?
Is the link above correct at all?
Is there documentation I missed?

In README of the snippets:
"
The openLilyLib Package

But the snippets repository is also a member of the family of
openLilyLib packages. In this family it is sort of an exception as
different from the other packages the snippets may also be used
directly, without making use of the central oll-core package.
"

Obviously wrong. :(

Nevertheless I can read the code, and Urs' approach _is_ different.
For what I can say without testing, it follows more the advice David
already gave in this thread.

Thanks,
  Harm

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

mclaren
  Stack-smashing is triggered by code inside the gcc compiler that's
designed to detect and avoid buffer overflows. What's happening
(probably) is that you're popping more values off the stack than you
pushed on and threatening to read into an illegal memory location just
beyond the pointer to which the bottom of the stack points.

  If you disable the protection variables in the gcc compiler that are
designed to serve as extra buffers on the stack by using
-fno-stack-protection, you'll get more information but also probably a
segfault and full crash. The segfault will occur due to the compiler
trying to read beyond the bottom of the stack into an illegal memory
location and the kernel calling a full halt due to the illegal
operation.

  The underlying reason for this error is probably that you're trying
to use too many points in the slur, which I would guess is handled by
pushing values onto and popping values off the stack that controls the
slur. This most likely results from trying to use a high-order
polynomial for the slur.

  There's no need to use a higher-order polynomial for the slur,
especially since this produce's Runge's Phenomenon, in which the slur
(polynomial curve) wiggles increasingly badly in between the control
points as the order of the polynomial rises.

https://en.wikipedia.org/wiki/Runge%27s_phenomenon

  A cubic spline should prove entirely adequate regardless of the
number of control points. A cubic spline avoids Runge's Phenomenon and
also yields a curve guaranteed to exhibit a smooth first and second
derivative, which is pretty much all you need. (Why would you need a
discontinuous 5th derivative, for example, in your slur?)

  Reducing the degree of the polynomial _should_ eliminate the
stack-smashing error. Guessing that the size of the stack used in the
slur is matched to the degree of the polynomial, and going to higher
order polynomials without changing the stack size produces the error.

  2nd or 3rd order spline polynomials should be perfectly adequate for
any reasonable slur it's possible to imagine. If you need sharp
discontinuous jumps during the slur, this can better be achieved by
ending the previous note and starting a new note with a new slur.
A discontinuity in the slur where the derivative becomes undefined is
the only reason I can imagine why you'd need a higher-order polynomial
for the spline that defines the slur.

  Remember that the number of control points is entirely unrelated to
the degree of the cubic spline. You can have 100 control points but
you will still only need a third degree polynomial for the cubic
spline.

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

benko.pal
In reply to this post by Thomas Morley-2
Thomas Morley <[hidden email]> ezt írta (időpont: 2019. ápr.
25., Cs, 18:57):
> > > So usually your goals would be better served by
> > > allowing _multiple_ cubic beziers in a row with suitable continuity of
> > > derivatives (and thus some aspects of the control points) provided
> > > automagically.
> >
> > which is called B-splines.  is it possible to use (cubic) B-splines directly?
>
> B-splines are also mentioned in one of the linked sources, but
> currently can't deal with them. I'll continue exploring ;)

it's well worth exploration; otherwise you'll just end up with something poorer.
the book I learned Bézier and B-splines from:
http://www.cin.ufpe.br/~mdlm/files/Farin-5a_edicao.pdf

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

Andrew Bernard
Hi Benko,

That's a good book, but it is copyright 2002 Academic Press. So it is not
freely distributable.

Generally speaking, since the lilypond community is strongly committed to
open source and its philosophy, suggesting violations of copyright are not
highly regarded. I am sorry to sound like a curmudgeon, but I think this is
an important principle related to intellectual property.

Having said that, I thank you for your recommendation and I believe I shall
buy that text, of which I was unaware.

Andrew



On Sat, 27 Apr 2019 at 04:06, Benkő Pál <[hidden email]> wrote:

>
>
> it's well worth exploration; otherwise you'll just end up with something
> poorer.
> the book I learned Bézier and B-splines from:
> http://www.cin.ufpe.br/~mdlm/files/Farin-5a_edicao.pdf
>
_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

benko.pal
Hi Andrew,

> That's a good book, but it is copyright 2002 Academic Press. So it is not freely distributable.
>
> Generally speaking, since the lilypond community is strongly committed to open source and its philosophy, suggesting violations of copyright are not highly regarded. I am sorry to sound like a curmudgeon, but I think this is an important principle related to intellectual property.

> Having said that, I thank you for your recommendation and I believe I shall buy that text, of which I was unaware.

Agreed.  I actually hesitated between sending this link or just
recommending the book, but since the link is on the first page of
google hits, I thought there's not much difference.  I should have
added an explicit caveat like "look into it then buy it, please, as
it's not free".

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

Thomas Morley-2
In reply to this post by benko.pal
Am Fr., 26. Apr. 2019 um 20:06 Uhr schrieb Benkő Pál <[hidden email]>:

>
> Thomas Morley <[hidden email]> ezt írta (időpont: 2019. ápr.
> 25., Cs, 18:57):
> > > > So usually your goals would be better served by
> > > > allowing _multiple_ cubic beziers in a row with suitable continuity of
> > > > derivatives (and thus some aspects of the control points) provided
> > > > automagically.
> > >
> > > which is called B-splines.  is it possible to use (cubic) B-splines directly?
> >
> > B-splines are also mentioned in one of the linked sources, but
> > currently can't deal with them. I'll continue exploring ;)
>
> it's well worth exploration; otherwise you'll just end up with something poorer.
> the book I learned Bézier and B-splines from:
> http://www.cin.ufpe.br/~mdlm/files/Farin-5a_edicao.pdf

Thanks for the hint.
More than 500 pages ... puuuuhh

Cheers,
  Harm

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: stack smashing detected

benko.pal
Thomas Morley <[hidden email]> ezt írta (időpont: 2019. ápr.
28., V, 15:13):
>
> Am Fr., 26. Apr. 2019 um 20:06 Uhr schrieb Benkő Pál <[hidden email]>:
> > the book I learned Bézier and B-splines from:
> > http://www.cin.ufpe.br/~mdlm/files/Farin-5a_edicao.pdf
>
> Thanks for the hint.
> More than 500 pages ... puuuuhh

oh, strictly speaking you'll need only about 40: first read the
chapters about Bézier curves to pick up terminology and style, then
jump to B-spline curves.

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel