Clean up by iiExprArith(Intern)

已查看 10 次
跳至第一个未读帖子

Jean-Pierre Flori

未读,
2016年10月25日 06:11:552016/10/25
收件人 libsingular-devel
Hello all,

I see that the following commit
* https://github.com/Singular/Sources/commit/86ce458e1269a1d57e682c12b9154dd1f1459354
claims that iiExprArithIntern does no clean up as iiExprArith does it.
But it seems to me iiExprArith directly returns when calling iiExprArithIntern:
* https://github.com/Singular/Sources/blob/spielwiese/Singular/iparith.cc#L8142

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!

Best,
JPF

Jean-Pierre Flori

未读,
2016年10月25日 06:30:582016/10/25
收件人 libsingular-devel
In particular in Sage, we clean up args for kernel functions :
* https://github.com/sagemath/sage/blob/master/src/sage/libs/singular/function.pyx#L1153
but not for library functions :
* https://github.com/sagemath/sage/blob/master/src/sage/libs/singular/function.pyx#L1068

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:
* https://github.com/sagemath/sage/blob/master/src/sage/libs/singular/function.pyx#L357

han...@mathematik.uni-kl.de

未读,
2016年11月2日 08:52:392016/11/2
收件人 libsingu...@googlegroups.com
> --
> 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 libsingular-de...@googlegroups.com.
> To post to this group, send email to libsingu...@googlegroups.com.
> Visit this group at https://groups.google.com/group/libsingular-devel.
> For more options, visit https://groups.google.com/d/optout.
Fixed with
https://github.com/Singular/Sources/commit/76a7291160a6ba0f7e662bf112de635f35663c1d

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.

Hans
回复全部
回复作者
转发
0 个新帖子