Segfault when printing a copy of symbolic object

6 views
Skip to first unread message

Jean-Pierre Flori

unread,
Oct 6, 2010, 10:18:23 AM10/6/10
to sage-support
Sage segfaults when printing a copy of something symbolics :

sage: copy(x)


------------------------------------------------------------
Unhandled SIGSEGV: A segmentation fault occurred in Sage.
This probably occurred because a *compiled* component
of Sage has a bug in it (typically accessing invalid memory)
or is not properly wrapped with _sig_on, _sig_off.
You might want to run Sage under gdb with 'sage -gdb' to debug this.
Sage will now terminate (sorry).
------------------------------------------------------------

I thought it could be because I messed up something in symbolics code.
But it also happens with the version distributed for Ubuntu, so if
someone confirms the bug, I'll open a ticket on Trac.

This does not happen with "deepcopy":

sage: deepcopy(x)
x

Dr. David Kirkby

unread,
Oct 6, 2010, 11:23:32 AM10/6/10
to sage-s...@googlegroups.com

I can confirm this - at least with sage-4.6.alpha1

drkirkby@hawk:~/sage-4.6.alpha1$ ./sage
----------------------------------------------------------------------
| Sage Version 4.6.alpha1, Release Date: 2010-09-18 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
**********************************************************************
* *
* Warning: this is a prerelease version, and it may be unstable. *
* *
**********************************************************************
sage: copy(x)


------------------------------------------------------------
Unhandled SIGSEGV: A segmentation fault occurred in Sage.
This probably occurred because a *compiled* component
of Sage has a bug in it (typically accessing invalid memory)
or is not properly wrapped with _sig_on, _sig_off.
You might want to run Sage under gdb with 'sage -gdb' to debug this.
Sage will now terminate (sorry).
------------------------------------------------------------


Dave


Dan Drake

unread,
Oct 6, 2010, 6:35:55 PM10/6/10
to sage-s...@googlegroups.com
On Wed, 06 Oct 2010 at 07:18AM -0700, Jean-Pierre Flori wrote:
> Sage segfaults when printing a copy of something symbolics :
>
> sage: copy(x)

I can confirm this for Sage 4.5 on OS X, although there I get:

------------------------------------------------------------
Unhandled SIGBUS: A bus error occurred in Sage.


This probably occurred because a *compiled* component
of Sage has a bug in it (typically accessing invalid memory)
or is not properly wrapped with _sig_on, _sig_off.
You might want to run Sage under gdb with 'sage -gdb' to debug this.
Sage will now terminate (sorry).
------------------------------------------------------------


Dan

--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------

signature.asc

Jason Grout

unread,
Oct 6, 2010, 7:36:46 PM10/6/10
to sage-s...@googlegroups.com

Just FYI, the version distributed with Ubuntu is *ages* old (in
Sage-time), and is not recommended to run.

Whoever makes a PPA for the current Sage release for Ubuntu would be
heralded a hero, I'm sure.

Jason

Justin C. Walker

unread,
Oct 6, 2010, 7:43:01 PM10/6/10
to sage-s...@googlegroups.com

On Oct 6, 2010, at 07:18 , Jean-Pierre Flori wrote:

> Sage segfaults when printing a copy of something symbolics :
>
> sage: copy(x)

I can confirm this for 4.6.a2 (Mac OS X, 10.6.4).

Justin

--
Justin C. Walker
Curmudgeon-at-large
Director
Institute for the Absorption of Federal Funds
----
186,000 Miles per Second
Not just a good idea:
it's the law!
----

Jean-Pierre Flori

unread,
Oct 7, 2010, 3:10:58 AM10/7/10
to sage-support
I was not clear.
I did not mean the version distributed in Ubuntu, I meant the binary
version distribution on Sage website for use with Ubuntu.

Cheers,

Dr. David Kirkby

unread,
Oct 7, 2010, 11:44:45 AM10/7/10
to sage-s...@googlegroups.com
On 10/ 6/10 03:18 PM, Jean-Pierre Flori wrote:
> Sage segfaults when printing a copy of something symbolics :
>
> sage: copy(x)

As I noted earlier, I see this on my machine (Sun Ultra 27 running OpenSolaris).
However, it must be relatively new, as I do *NOT* see the segfault at

http://t2nb.math.washington.edu:8000

which is running Sage 4.5.1. That said, that's a big-endian machine, which could
just be relevant.

Dave

kcrisman

unread,
Oct 7, 2010, 3:55:21 PM10/7/10
to sage-support


On Oct 7, 11:44 am, "Dr. David Kirkby" <david.kir...@onetel.net>
wrote:
Conceivable, since it's definitely not new, as I get

----------------------------------------------------------------------
| Sage Version 4.4.4, Release Date: 2010-06-23 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
Loading Sage library. Current Mercurial branch is: hackbranch
sage: copy(x)


------------------------------------------------------------
Unhandled SIGSEGV: A segmentation fault occurred in Sage.
This probably occurred because a *compiled* component
of Sage has a bug in it (typically accessing invalid memory)
or is not properly wrapped with _sig_on, _sig_off.
You might want to run Sage under gdb with 'sage -gdb' to debug this.
Sage will now terminate (sorry).
------------------------------------------------------------

While on my PPC OS X 10.4 machine, I just get a long hang (this is
4.6.alpha2) with no output.

So at any rate the behavior is very machine-dependent at this point,
but not really ideal on any of them (with the possible exception of
t2).

- kcrisman

kcrisman

unread,
Oct 7, 2010, 4:05:35 PM10/7/10
to sage-support


> While on my PPC OS X 10.4 machine, I just get a long hang (this is
> 4.6.alpha2) with no output.
>

More precisely, with sage -gdb I get

sage: copy(x)

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
GiNaC::ex::print (this=0x0, c=@0xbfffc698, level=0) at ex.cpp:58
58 ex.cpp: No such file or directory.
in ex.cpp
Current language: auto; currently c++

I bet THIS helps someone.

- kcrisman

Dr. David Kirkby

unread,
Oct 7, 2010, 5:02:15 PM10/7/10
to sage-s...@googlegroups.com

Worth noting is the PPC and SPARC are both big endian, so the fact it is ok on
t2 does not mean it's only a problem on little endian machines.

When Sage builds, there are around 3000 warnings messages from the compilers. I
can't help feeling we should be spending a bit more time looking over those, and
a bit less time adding new features.

Dave

kcrisman

unread,
Oct 7, 2010, 8:14:15 PM10/7/10
to sage-support
Yes, but see my second message in this thread, where sage -gdb finds
something nasty.

> When Sage builds, there are around 3000 warnings messages from the compilers. I
> can't help feeling we should be spending a bit more time looking over those, and
> a bit less time adding new features.

Perhaps, but there is a very finite amount of time available. As well
as expertise - I can report a bug, but have no idea about compiler
options (though I'm learning). But we've had this discussion before -
I think that with incremental but very useful changes such as the
current Numpy/Scipy ticket we will get there, while not holding up
development (and hence interest and use) in other areas.

- kcrisman

Dr. David Kirkby

unread,
Oct 7, 2010, 8:48:36 PM10/7/10
to sage-s...@googlegroups.com

It is crashing while executing code which is part of of the pynac package, more
precisely this file:

./sage-4.6.alpha2/pynac-0.2.0.p5/src/ginac/ex.cpp

It is now

http://trac.sagemath.org/sage_trac/ticket/10099

Dave

Mike Hansen

unread,
Oct 7, 2010, 8:50:43 PM10/7/10
to sage-s...@googlegroups.com
It doesn't have anything to do with the compiler warning messages --
the problem is much simpler than that. The implementation of
Element.__copy__ is wrong for Expression objects; namely, it doesn't
set the _gobj attribute. To fix it, we just add a proper
implementation of copy:

def __copy__(self):
return new_Expression_from_GEx(self._parent, self._gobj)

--Mike

kcrisman

unread,
Oct 7, 2010, 9:25:00 PM10/7/10
to sage-support
LOL - I should have checked that! Trac isn't working now - can you or
drkirkby put that on the ticket when it comes back up?

- kcrisman

Mike Hansen

unread,
Oct 7, 2010, 9:26:07 PM10/7/10
to sage-s...@googlegroups.com
On Thu, Oct 7, 2010 at 6:25 PM, kcrisman <kcri...@gmail.com> wrote:
> LOL - I should have checked that!  Trac isn't working now - can you or
> drkirkby put that on the ticket when it comes back up?

I've already posted a patch.

--Mike

Dr. David Kirkby

unread,
Oct 8, 2010, 4:11:36 AM10/8/10
to sage-s...@googlegroups.com

It works for me, as I remarked at

http://trac.sagemath.org/sage_trac/ticket/10099

However, I don't feel able to review completely myself, as I don't understand
this. But I can report it works on my OpenSolaris machine.

dave

Jean-Pierre Flori

unread,
Oct 8, 2010, 9:13:31 AM10/8/10
to sage-support
I can confirm it fixes the bug, I'll add myself as a reviewer on Trac.

If I understand correctly, originally, __copy__ function of
element.pyx calls Expression.__new__(Expression) which should call an
__init__ function (without argument ? but I don't know which ?) so
_gobj is not initialized.
When you try to call Expression() without argument you get an error
because the only __init__ function defined in expression.pyx needs 1
argument (the symbolic ring used).
Can someone clarify what is happening ?
Reply all
Reply to author
Forward
0 new messages