Clean up by iiExprArith(Intern)

Skip to first unread message

Jean-Pierre Flori

Oct 25, 2016, 6:11:55 AM10/25/16
to libsingular-devel
Hello all,

I see that the following commit
claims that iiExprArithIntern does no clean up as iiExprArith does it.
But it seems to me iiExprArith directly returns when calling iiExprArithIntern:

This unfortunately makes Sage code segfault when going from 4.0.3p3 to 4.0.3p4 although I thing that Sage's code is also faulty.
What we do is calling iiExprArith and then calling the CleanUp function on the args we passed to it, with for some reason the ring set to NULL.

Before it was ok because the iiExprArithIntern already called the CleanUp function with the ring set and the args were cleaned up within the call to iiExprArith.
Therefore when Sage called a second time on the args without a ring set, the args were already empty and the CleanUp function did nothing.

Now when iiExprArith returns the args are not cleaned up anymore.
We then call the CleanUp function on them with a ring set to NULL and boom.

Any advice welcome!


Jean-Pierre Flori

Oct 25, 2016, 6:30:58 AM10/25/16
to libsingular-devel
In particular in Sage, we clean up args for kernel functions :
but not for library functions :

I don't know enough to tell why we do so.
Although the previous message shows there is an issue.

Maybe the difference is just about calling omFreeBin in the kernel case ourselves but not in the library case.
And we should never care about sleftv::CleanUp.
These are the only things our free_leftv function does:

Nov 2, 2016, 8:52:39 AM11/2/16
> --
> You received this message because you are subscribed to the Google Groups
> "libsingular-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
> To post to this group, send email to
> Visit this group at
> For more options, visit
Fixed with

Calls to iiExprArith[1-3] shall provide pointers to the arguments (leftv).
For these arguments sleftv::CleanUp(currRing) is called - no need to do
it in Sage, but an additional CleanUp does not harm.
So the contents of these arguments are recycled,
but the memory blocks itself remain (because in Singular they are not
dynamic storage blocks but part of an array): omFree (or the
corresponding free-routine to the allocation) must be called.

For functions with a variable number of arguments (iiExprArithM) the
arguments are passed as a linked list and CleanUp recycles all content
and all memory blocks but the first - they must be allocted by routines
from omalloc.

Calling library function should be equivalent to iiExprArithM.

Reply all
Reply to author
0 new messages