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

Fix sqrt(sqrt(2)) memory leak in ginac numeric.cpp #36046

Merged
merged 3 commits into from
Aug 27, 2023

Conversation

vbraun
Copy link
Member

@vbraun vbraun commented Aug 8, 2023

Fix the memory leak when computing the outer sqrt in sqrt(sqrt(2)), as reported on sage devel at https://groups.google.com/g/sage-devel/c/6zpxQKXtJgk

The unit test is a WIP and depends on tekknolagi/valgrind#1

@vbraun vbraun force-pushed the u/vbraun/fix-mem-leak-sqrt-sqrt-2 branch from 5723eea to 2286629 Compare August 13, 2023 18:35
@vbraun
Copy link
Member Author

vbraun commented Aug 13, 2023

Note to self: the numeric::numeric ctor transfers ownership of the mpz_t, so no clear in that one code path. Tests pass now!

Setting this to needs review for now, a better valgrind integration needs the pypi/valgrind PR that will be tracked there.

@github-actions
Copy link

Documentation preview for this PR (built with commit 2286629; changes) is ready! 🎉

@mkoeppe
Copy link
Member

mkoeppe commented Aug 13, 2023

Use the new .supp file in src/bin/sage-valgrind too?

@vbraun
Copy link
Member Author

vbraun commented Aug 14, 2023

sage-valgrind has bigger problems than the suppression file, it instruments the shell launching python and not python itself. I'd rather leave fixing it for a separate ticket.

Copy link
Member

@mkoeppe mkoeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tornaria
Copy link
Contributor

Works for me, thanks!

vbraun pushed a commit to vbraun/sage that referenced this pull request Aug 23, 2023
    
Fix the memory leak when computing the outer sqrt in `sqrt(sqrt(2))`, as
reported on sage devel at https://groups.google.com/g/sage-
devel/c/6zpxQKXtJgk

The unit test is a WIP and depends on
tekknolagi/valgrind#1

- Resolves sagemath#33074
    
URL: sagemath#36046
Reported by: Volker Braun
Reviewer(s): Matthias Köppe
@vbraun vbraun merged commit aededc6 into sagemath:develop Aug 27, 2023
14 of 16 checks passed
@mkoeppe mkoeppe added this to the sage-10.2 milestone Aug 27, 2023
@mkoeppe mkoeppe mentioned this pull request Mar 8, 2024
5 tasks
@tscrim tscrim mentioned this pull request Aug 6, 2024
5 tasks
vbraun pushed a commit to vbraun/sage that referenced this pull request Aug 27, 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". -->

As noted in
sagemath#36046 (comment),
`sage -t --valgrind` does not work because it instruments the wrong
process.

As part of the fix, we move the contents of `src/bin/sage-runtests` to
`src/bin/sage/doctest/__main__.py` so that the doctester can be invoked
as `sage -python -m sage.doctest`.

We also arrange for `sage -t --valgrind` to use the suppressions file
added in sagemath#36046.

### 📝 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.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ 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#37569
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
vbraun pushed a commit to vbraun/sage that referenced this pull request Sep 5, 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". -->

As noted in
sagemath#36046 (comment),
`sage -t --valgrind` does not work because it instruments the wrong
process.

As part of the fix, we move the contents of `src/bin/sage-runtests` to
`src/bin/sage/doctest/__main__.py` so that the doctester can be invoked
as `sage -python -m sage.doctest`.

We also arrange for `sage -t --valgrind` to use the suppressions file
added in sagemath#36046.

### 📝 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.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ 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#37569
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
vbraun pushed a commit to vbraun/sage that referenced this pull request Sep 6, 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". -->

As noted in
sagemath#36046 (comment),
`sage -t --valgrind` does not work because it instruments the wrong
process.

As part of the fix, we move the contents of `src/bin/sage-runtests` to
`src/bin/sage/doctest/__main__.py` so that the doctester can be invoked
as `sage -python -m sage.doctest`.

We also arrange for `sage -t --valgrind` to use the suppressions file
added in sagemath#36046.

### 📝 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.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ 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#37569
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
vbraun pushed a commit to vbraun/sage that referenced this pull request Sep 8, 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". -->

As noted in
sagemath#36046 (comment),
`sage -t --valgrind` does not work because it instruments the wrong
process.

As part of the fix, we move the contents of `src/bin/sage-runtests` to
`src/bin/sage/doctest/__main__.py` so that the doctester can be invoked
as `sage -python -m sage.doctest`.

We also arrange for `sage -t --valgrind` to use the suppressions file
added in sagemath#36046.

### 📝 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.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ 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#37569
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
vbraun pushed a commit to vbraun/sage that referenced this pull request Sep 8, 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". -->

As noted in
sagemath#36046 (comment),
`sage -t --valgrind` does not work because it instruments the wrong
process.

As part of the fix, we move the contents of `src/bin/sage-runtests` to
`src/bin/sage/doctest/__main__.py` so that the doctester can be invoked
as `sage -python -m sage.doctest`.

We also arrange for `sage -t --valgrind` to use the suppressions file
added in sagemath#36046.

### 📝 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.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ 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#37569
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
vbraun pushed a commit to vbraun/sage that referenced this pull request Sep 10, 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". -->

As noted in
sagemath#36046 (comment),
`sage -t --valgrind` does not work because it instruments the wrong
process.

As part of the fix, we move the contents of `src/bin/sage-runtests` to
`src/bin/sage/doctest/__main__.py` so that the doctester can be invoked
as `sage -python -m sage.doctest`.

We also arrange for `sage -t --valgrind` to use the suppressions file
added in sagemath#36046.

### 📝 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.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ 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#37569
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
vbraun pushed a commit to vbraun/sage that referenced this pull request Sep 12, 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". -->

As noted in
sagemath#36046 (comment),
`sage -t --valgrind` does not work because it instruments the wrong
process.

As part of the fix, we move the contents of `src/bin/sage-runtests` to
`src/bin/sage/doctest/__main__.py` so that the doctester can be invoked
as `sage -python -m sage.doctest`.

We also arrange for `sage -t --valgrind` to use the suppressions file
added in sagemath#36046.

### 📝 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.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ 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#37569
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
vbraun pushed a commit to vbraun/sage that referenced this pull request Sep 14, 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". -->

As noted in
sagemath#36046 (comment),
`sage -t --valgrind` does not work because it instruments the wrong
process.

As part of the fix, we move the contents of `src/bin/sage-runtests` to
`src/bin/sage/doctest/__main__.py` so that the doctester can be invoked
as `sage -python -m sage.doctest`.

We also arrange for `sage -t --valgrind` to use the suppressions file
added in sagemath#36046.

### 📝 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.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ 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#37569
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update valgrind suppressions
4 participants