-
-
Notifications
You must be signed in to change notification settings - Fork 564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when expanding square root of -x #30688
Comments
comment:1
Not the backtranslation from Maxima (or not only) ; I have the same problem backtranslating from Sympy :
This seems to point to |
comment:2
#30378 seems relevant. |
comment:3
The error is trigerred by the existence of the assumption about This works:
This crashes Sage:
Ditto when using |
comment:4
Given that our release is long overdue, and nobody works on the present ticket, I turn it to critical. ANybody proposing a branch in the next few days can of course reconsider this. |
comment:5
Replying to @fchapoton:
I'd be delighted to work on this, but the problem resides in Cythonized library code, the care and feeding of which I haven't the slightest idea... Do you have pointers to an introduction to working on Sage library code ? |
comment:6
A very quick check with Cocalc's available kernels (back to 8.2) shows that the following:
crashed even in 8.2 days... |
comment:7
Mark as |
comment:8
Might be related to #30446. |
comment:9
Replying to @mjungmath:
still the example from comment:6 with #30446 installed leads to a crash. It certainly should not be a blocker, though. There are many other ways to crash Sage, after all. |
comment:10
Here is a shorter session that demonstrates the crash:
On
|
comment:11
I think the problem is even worse than it appeared.
I think you can replace |
comment:12
I think I found the bug. The definition of the
This is part of the code that calculates the expansion of a power of a product: I think it will be easy to fix. I can't do it right now, but I should have time to write a patch in the next couple of days. |
comment:13
Thanks for working on this. As you know, pynac is based on an old fork of ginac - so the question is also whether this bug was fixed upstream. |
comment:14
This is what one has in Ginac upstream: https://ginac.de/reference/power_8cpp_source.html // search for positive/negative factors
for (auto & cit : m.seq) {
ex e=m.recombine_pair_to_ex(cit);
if (e.info(info_flags::positive))
prodseq.push_back(pow(e, exponent).expand(options));
else if (e.info(info_flags::negative)) {
prodseq.push_back(pow(-e, exponent).expand(options));
possign = !possign;
} else
powseq.push_back(cit);
} Looks like it's still basically the same, but I'm not 100% sure. |
comment:15
I don't know c++ or ginac, but I don't see any meaningful difference, so I don't think the ginac upstream fixed this. Patching pynac to comment out the
If we fix the clause, then I think the output would instead be I will think about how to do that, but it's great if someone who knows something about ginac (and/or c++) wants to chime in. |
Branch: public/30688 |
comment:17
Setting to "needs review" to ask the patchbots whether they think that deleting the dimpase already knows this, but for others who are following the thread: As pointed out by mkoeppe in #30446 comment:17, we will actually need a new pynac tarball, not just a patch, when we have decided how to fix this. But I think a patch is good enough for now. New commits:
|
Commit: |
comment:20
Opened pynac/pynac#368 - hopefully people knowing GiNaC code can comment. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:22
I suggest we close this critical ticket by applying my patch that comments out the I don't know anything about packaging and making tarballs. @dimpase, would that be easy for you to do? (Or perhaps add it to the tarball in #30446?) I could probably figure out how to post a PR to https://github.com/pynac/pynac, if that would be helpful. I downloaded vanilla ginac and did some testing in C++. I was unable to get an infinite loop. It may be there, but it is definitely harder to access there than in sage. For example, vanilla ginac does not provide a straightforward way to declare a variable to be negative. (Of course, my lack of expertise is also an issue.)
The expression |
This comment has been minimized.
This comment has been minimized.
comment:23
Replying to @DaveWitteMorris:
Commenting out the whole
we can just do a package patch, no need to make a new tarball.
Could you put your try somewhere on the github?
yes, this looks to be the case. A proper way to fix this might be to get the |
comment:24
I think that almost every calculation that uses the Do I need to do something to get the patchbots to test this PR? I edited |
comment:25
I tried lots of things, but here is the best one that I could come up with by using my almost nonexistent understanding of ginac and c++:
After a warning message from
I think the If I change
This means that the |
Dependencies: #30446 |
Reviewer: Dima Pasechnik |
comment:26
OK, I'm at loss here. Anyway,let's get your patch in, but please rebase it over |
Changed branch from public/30688 to public/30688r1 |
comment:28
OK, I always having trouble doing a rebase, but I think I eventually got it correct. I changed the package version to 0.7.27.p1 -- is that correct? Last 10 new commits:
|
Author: Dave Morris |
comment:29
Followup ticket: I opened #31337 for reimplementing the |
comment:31
OK,good. |
Changed branch from public/30688r1 to |
Changed commit from |
Before this ticket, this crashes Sage:
See comment:12 for an explanation of the cause.
Original title and description:
Some algebraic substitutions may crash Sage
History : see this sage-release post and the following.
TL;DR: Sage crashes reproducibly on some substitutions:
This may result from an incorrect backtranslation from Maxima:
I mark this as
blocker
since it crashes Sage on (relatively) trivial algebraic operations.Interestingly, I can't reproduce the problem in expression coming from another source:
Since this problem appears in compiled code, I don't (yet) know how to tackle it. Advice welcome...
Depends on #30446
CC: @kcrisman @slel
Component: symbolics
Author: Dave Morris
Branch:
20067d3
Reviewer: Dima Pasechnik
Issue created by migration from https://trac.sagemath.org/ticket/30688
The text was updated successfully, but these errors were encountered: