Skip to content
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

PowerSeriesRing(QQ, 10) raises unhelpful exception #6

Closed
sagetrac-dmharvey mannequin opened this issue Sep 12, 2006 · 2 comments
Closed

PowerSeriesRing(QQ, 10) raises unhelpful exception #6

sagetrac-dmharvey mannequin opened this issue Sep 12, 2006 · 2 comments

Comments

@sagetrac-dmharvey
Copy link
Mannequin

sagetrac-dmharvey mannequin commented Sep 12, 2006

PowerSeriesRing(QQ, 10) crashes SAGE:

Traceback (most recent call last):
PowerSeriesRing(QQ, 10)
File "/home/server/", line 1, in ?

File "/sage/local/lib/python2.4/site-packages/sage/rings/power_series_ring.py",
line 44, in PowerSeriesRing
R = PowerSeriesRing_over_field(base_ring, name, default_prec)
File "/sage/local/lib/python2.4/site-packages/sage/rings/power_series_ring.py",
line 171, in __init__
PowerSeriesRing_generic.init(self, base_ring, name, default_prec)
File "/sage/local/lib/python2.4/site-packages/sage/rings/power_series_ring.py",
line 63, in __init__
self.__generator = self.__power_series_class(self, [0,1], check=True,
is_gen=True)
File
"/sage/local/lib/python2.4/site-packages/sage/rings/power_series_ring_element.py",
line 506, in __init__
f = R(f, check=check)
File "/sage/local/lib/python2.4/site-packages/sage/rings/multi_polynomial_ring.py",
line 481, in __call__
c = self.base_ring()(x)
File "/sage/local/lib/python2.4/site-packages/sage/rings/rational_field.py", line
155, in __call__
return sage.rings.rational.Rational(x, base)
File "rational.pyx", line 105, in rational.Rational.init
File "rational.pyx", line 183, in rational.Rational.__set_value
TypeError: Unable to coerce [0, 1] (<type 'list'>) to Rational

Component: basic arithmetic

Issue created by migration from https://trac.sagemath.org/ticket/6

Repository owner changed the title PowerSeriesRing(QQ, 10) crashes SAGE PowerSeriesRing(QQ, 10) raises exception Sep 12, 2006
@ghost
Copy link

ghost commented Sep 12, 2006

comment:2

Ah. I thought that second parameter was the precision. It's actually a variable name. Still, it shouldn't be crashing like this :-)

Repository owner added p: minor / 4 and removed p: major / 3 labels Sep 12, 2006
Repository owner changed the title PowerSeriesRing(QQ, 10) raises exception PowerSeriesRing(QQ, 10) raises unhelpful exception Sep 12, 2006
@williamstein
Copy link
Contributor

comment:3

Fixed

def PowerSeriesRing(base_ring, name=None, default_prec=20):
    """
    EXAMPLES:
        sage: R = PowerSeriesRing(QQ); R
        Power Series Ring in x over Rational Field

        sage: S = PowerSeriesRing(QQ, 'y'); S
        Power Series Ring in y over Rational Field
        
        sage: R = PowerSeriesRing(QQ, 10)
        Traceback (most recent call last):
        ...
        TypeError: variable name must be a string or None

        sage: S = PowerSeriesRing(QQ, default_prec = 15); S
        Power Series Ring in x over Rational Field
        sage: S.default_prec()
        15
    """
    #global _objsPowerSeriesRing
    #key = (base_ring, name, default_prec)
    #if _objsPowerSeriesRing.has_key(key):
    #    x = _objsPowerSeriesRing[key]()
    #    if x != None: return x

    if not (name is None or isinstance(name, str)):
        raise TypeError, "variable name must be a string or None"
        
                  
    if isinstance(base_ring, field.Field):
        R = PowerSeriesRing_over_field(base_ring, name, default_prec)
    elif isinstance(base_ring, integral_domain.IntegralDomain):
        R = PowerSeriesRing_domain(base_ring, name, default_prec)
    elif isinstance(base_ring, commutative_ring.CommutativeRing):
        R = PowerSeriesRing_generic(base_ring, name, default_prec)
    else:
        raise TypeError, "base_ring must be a commutative ring"
    #_objsPowerSeriesRing[key] = weakref.ref(R)
    return R

vbraun pushed a commit that referenced this issue Mar 26, 2023
    
### 📚 Description

Trac branch `u/gh-collares/gap-gc` from #34701, now migrated to GitHub.
Currently based atop #35093; will rebase once that is merged.

The rest of the description below is copied from #34701:

A refactor in #27946 introduced "unprotected" (not surrounded by
`GAP_Enter`/`GAP_Leave`) `GAP_ValueGlobalVariable` calls. I believe this
might be a GC hazard, because after updating to GAP 4.12.1 I started
seeing aarch64 crashes on NixOS infrastructure such as:

```
#0  0x0000fffff79740e8 in wait4 ()
#1  0x0000fffff5dc6b78 in print_enhanced_backtrace ()
#2  0x0000fffff5dc8190 in sigdie ()
#3  0x0000fffff5dcb1c0 in cysigs_signal_handler ()
#4  0x0000fffff7ffb7cc in __kernel_rt_sigreturn ()
#5  0x0000ffff99a0bf28 in ConvString ()
#6  0x0000000000000000 in ?? ()
#7  0x0000000000000000 in ?? ()
#8  0x0000000000000000 in ?? ()
#9  0x0000ffff99989930 in Pr ()
#10 0x0000ffff9998aa18 in CloseOutput ()
#11 0x0000ffff99884828 in capture_stdout () at /build/sage-
src-9.7/pkgs/sagemath-standard/sage/libs/gap/element.pyx:154
...
```
I also see cases where `capture_stdout` throws errors such as
`sage.libs.gap.util.GAPError: Error, Length: <list> must be a list (not
the integer 255)` and then crashes. Both types of errors are fixed by
this ticket.

Note that I am nesting `GAP_Enter`/`GAP_Leave` calls because I didn't
remove the preexisting calls inside `capture_stdout`. That's because I
feared removing the innermost calls might create a new footgun (and I
believe nested `GAP_Enter`/`GAP_Leave` calls are explicitly supported),
but removing them should cause no problem. Removing them might even be
preferable for performance reasons, I don't know.

Fixes #34701

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [x] I have made sure that the title is self-explanatory and the
description concisely explains the PR.
- [x] I have linked an issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies
<!-- List all open pull requests that this PR logically depends on -->
<!--
- #xyz: short description why this is a dependency
- #abc: ...
-->
- #35093: GAP 4.12.2 upgrade, which touches the same function and should
land first.
    
URL: #35114
Reported by: Mauricio Collares
Reviewer(s): Dima Pasechnik
vbraun pushed a commit to vbraun/sage that referenced this issue Sep 14, 2023
vbraun pushed a commit to vbraun/sage that referenced this issue Jul 20, 2024
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

EOL 2024-06-30, CI now fails https://github.com/mkoeppe/sage/actions/run
s/9970528956/job/27549649531#step:11:66
```
sagemath#6 [with-system-packages 2/4] RUN yum install -y centos-release-scl
sagemath#6 0.267 Loaded plugins: fastestmirror, ovl
sagemath#6 0.357 Determining fastest mirrors
sagemath#6 0.867 Could not retrieve mirrorlist http://mirrorlist.centos.org/?rel
ease=7&arch=x86_[64](https://github.com/mkoeppe/sage/actions/runs/997052
8956/job/27549649531#step:11:65)&repo=os&infra=container error was
sagemath#6 0.867 14: curl#6 - "Could not resolve host: mirrorlist.centos.org;
Unknown error"
```

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#38380
Reported by: Matthias Köppe
Reviewer(s): Frédéric Chapoton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants