10000 Fix unhandled C++ exception by cgohlke · Pull Request #13289 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix unhandled C++ exception #13289

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

Merged
merged 2 commits into from
Feb 2, 2019
Merged

Fix unhandled C++ exception #13289

merged 2 commits into from
Feb 2, 2019

Conversation

cgohlke
Copy link
Contributor
@cgohlke cgohlke commented Jan 25, 2019

The C++ new operator will throw an C++ exception when the memory allocation fails.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

The C++ new operator will throw an C++ exception when the memory allocation fails.
@tacaswell tacaswell added this to the v3.0.3 milestone Jan 25, 2019
src/_tkagg.cpp Outdated
try {
destbuffer = new agg::int8u[deststride * destheight];
}
catch (...) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to catch everything? Is std::bad_alloc not enough?

Copy link
Member

Choose a reason for hiding this comment

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

@cgohlke Any change you could reply to @QuLogic's comment? I agree with him on narrowing down the exception catch unless there's a specific reason not to.

@NelleV NelleV merged commit 9c1d70b into matplotlib:master Feb 2, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Feb 2, 2019
@NelleV
Copy link
Member
NelleV commented Feb 2, 2019

Thanks!

tacaswell added a commit that referenced this pull request Feb 4, 2019
…289-on-v3.0.x

Backport PR #13289 on branch v3.0.x (Fix unhandled C++ exception)
try {
destbuffer = new agg::int8u[deststride * destheight];
}
catch (std::bad_alloc) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should have been a catch-by-reference; right now gcc warns:

src/_tkagg.cpp: In function ‘int PyAggImagePhoto(ClientData, Tcl_Interp*, int, char**)’:
src/_tkagg.cpp:121:21: warning: catching polymorphic type ‘class std::bad_alloc’ by value [-Wcatch-value=]
         catch (std::bad_alloc) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0