{"push_id":1314015505,"size":1,"distinct_size":1,"ref":"refs/heads/master","head":"503b1c39dc801389f7ae510fb1f7ee1e533b67ac","before":"5025eb7c0d87b01507116353b5d63b163d7add3d","commits":[{"sha":"503b1c39dc801389f7ae510fb1f7ee1e533b67ac","author":{"name":"Pedro Alves","email":"4ab1b1e93a96e2379fea7b286ce33d45682708c9@redhat.com"},"message":"gdb: Replace operator new / operator new[]\n\nIf xmalloc fails allocating memory, usually because something tried a\nhuge allocation, like xmalloc(-1) or some such, GDB asks the user what\nto do:\n\n  .../src/gdb/utils.c:1079: internal-error: virtual memory exhausted.\n  A problem internal to GDB has been detected,\n  further debugging may prove unreliable.\n  Quit this debugging session? (y or n)\n\nIf the user says \"n\", that throws a QUIT exception, which is caught by\none of the multiple CATCH(RETURN_MASK_ALL) blocks somewhere up the\nstack.\n\nThe default implementations of operator new / operator new[] call\nmalloc directly, and on memory allocation failure throw\nstd::bad_alloc.  Currently, if that happens, since nothing catches it,\nthe exception escapes out of main, and GDB aborts from unhandled\nexception.\n\nThis patch replaces the default operator new variants with versions\nthat, just like xmalloc:\n\n #1 - Raise an internal-error on memory allocation failure.\n\n #2 - Throw a QUIT gdb_exception, so that the exact same CATCH blocks\n      continue handling memory allocation problems.\n\nA minor complication of #2 is that operator new can _only_ throw\nstd::bad_alloc, or something that extends it:\n\n  void* operator new (std::size_t size) throw (std::bad_alloc);\n\nThat means that if we let a gdb QUIT exception escape from within\noperator new, the C++ runtime aborts due to unexpected exception\nthrown.\n\nSo to bridge the gap, this patch adds a new gdb_quit_bad_alloc\nexception type that inherits both std::bad_alloc and gdb_exception,\nand throws _that_.\n\nIf we decide that we should be catching memory allocation errors in\nfewer places than all the places we currently catch them (everywhere\nwe use RETURN_MASK_ALL currently), then we could change operator new\nto throw plain std::bad_alloc then.  But I'm considering such a change\nas separate matter from this one -- it'd make sense to do the same to\nxmalloc at the same time, for instance.\n\nMeanwhile, this allows using new/new[] instead of xmalloc/XNEW/etc.\nwithout losing the \"virtual memory exhausted\" internal-error\nsafeguard.\n\nTested on x86_64 Fedora 23.\n\ngdb/ChangeLog:\n2016-09-23  Pedro Alves  <palves@redhat.com>\n\n\t* Makefile.in (SFILES): Add common/new-op.c.\n\t(COMMON_OBS): Add common/new-op.o.\n\t(new-op.o): New rule.\n\t* common/common-exceptions.h: Include <new>.\n\t(struct gdb_quit_bad_alloc): New type.\n\t* common/new-op.c: New file.\n\ngdb/gdbserver/ChangeLog:\n2016-09-23  Pedro Alves  <palves@redhat.com>\n\n\t* Makefile.in (SFILES): Add common/new-op.c.\n\t(OBS): Add common/new-op.o.\n\t(new-op.o): New rule.","distinct":true,"url":"https://api.github.com/repos/wallento/binutils-gdb/commits/503b1c39dc801389f7ae510fb1f7ee1e533b67ac"}]}
{"actor":{"display_login":"wallento"}}