RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc
Hi Sergey, thanks for checking . @Christoph : copyright years updated in the cpp files . @Phil , I checked the indentation it looked indeed strange in the udiff however in the cpp file itself it looks ok to me . Thanks for the reviews and best regards, Matthias > -Original Message- > From: Phil Race [mailto:philip.r...@oracle.com] > Sent: Dienstag, 5. Juni 2018 23:41 > To: Sergey Bylokhov ; Baesken, Matthias > ; Langer, Christoph > ; Thomas Stüfe ; > 'build-dev@openjdk.java.net' ; awt- > d...@openjdk.java.net > Cc: 2d-dev <2d-...@openjdk.java.net> > Subject: Re: RFR: JDK-8204211: windows : handle potential C++ exception in > GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using > SAFE_SIZE_ARRAY_ALLOC / safe_Malloc > > > In that case Matthias is good to go after fixing the indentation. > > -phil. > > On 06/05/2018 01:37 PM, Sergey Bylokhov wrote: > > I have checked the fix using mach5. > > > > On 05/06/2018 12:45, Phil Race wrote: > >> Oh .. can I please ask that you make sure that VS2017 is OK with the > >> re-enabled > >> warning ? I seriously doubt that it has anything new to add over > >> VS2013, but a jdk-submit > >> will tell you if it has .. > >> > >> VS2017 is now the default so a jdk-submit will use that. > >> > >> -phil. > >> > >> On 06/05/2018 12:43 PM, Phil Race wrote: > >>> This looks good to me except for what looks like in my browser like > >>> missing indentation in > >>> > http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/src/java.deskto > p/windows/native/libawt/java2d/windows > >>> > >>> /GDIRenderer.cpp.udiff.html > >>> > >>> You can fix that with or without an updated webrev. > >>> > >>> Good to clear a class of warnings. > >>> > >>> -phil. > >>> > >>> On 06/05/2018 12:47 AM, Baesken, Matthias wrote: > >>>> Hi Christoph, thank's for the review . > >>>> Could I have a second one for example from the awt or build-dev > >>>> reviewers ? > >>>> > >>>> Best Regards, Matthias > >>>> > >>>> > >>>>> -Original Message- > >>>>> From: Langer, Christoph > >>>>> Sent: Montag, 4. Juni 2018 16:49 > >>>>> To: Baesken, Matthias ; Thomas Stüfe > >>>>> ; 'build-dev@openjdk.java.net' >>>>> d...@openjdk.java.net>; awt-...@openjdk.java.net > >>>>> Cc: 2d-dev <2d-...@openjdk.java.net> > >>>>> Subject: RE: RFR: JDK-8204211: windows : handle potential C++ > >>>>> exception in > >>>>> GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using > >>>>> SAFE_SIZE_ARRAY_ALLOC / safe_Malloc > >>>>> > >>>>> Hi Matthias, > >>>>> > >>>>> looks good to me. > >>>>> > >>>>> Don't forget the Copyright years. > >>>>> > >>>>> Best regards > >>>>> Christoph > >>>>> > >>>>>> -Original Message- > >>>>>> From: Baesken, Matthias > >>>>>> Sent: Montag, 4. Juni 2018 16:20 > >>>>>> To: Thomas Stüfe ; 'build- > >>>>>> d...@openjdk.java.net' ; awt- > >>>>>> d...@openjdk.java.net > >>>>>> Cc: 2d-dev <2d-...@openjdk.java.net>; Langer, Christoph > >>>>>> > >>>>>> Subject: RE: RFR: JDK-8204211: windows : handle potential C++ > >>>>>> exception in > >>>>>> GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using > >>>>>> SAFE_SIZE_ARRAY_ALLOC / safe_Malloc > >>>>>> > >>>>>> Hello, I prepared a second webrev. > >>>>>> > >>>>>> - use now const-reference in the catch-statements as suggested by > >>>>> Thomas > >>>>>> - reenabled the cl warning showing the exception issues in > >>>>>> make/lib/Awt2dLibraries.gmk > >>>>>> - found a second place in WPrinterJob.cpp with similar issues > >>>>>> after > >>>>>> reenabling the warnings > >>>>>> > >>>>>> Please review : > >>>>>> > >>>>>> http://cr.openjdk.java.net/~mbaesken/webrevs/820
Re: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc
In that case Matthias is good to go after fixing the indentation. -phil. On 06/05/2018 01:37 PM, Sergey Bylokhov wrote: I have checked the fix using mach5. On 05/06/2018 12:45, Phil Race wrote: Oh .. can I please ask that you make sure that VS2017 is OK with the re-enabled warning ? I seriously doubt that it has anything new to add over VS2013, but a jdk-submit will tell you if it has .. VS2017 is now the default so a jdk-submit will use that. -phil. On 06/05/2018 12:43 PM, Phil Race wrote: This looks good to me except for what looks like in my browser like missing indentation in http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/src/java.desktop/windows/native/libawt/java2d/windows /GDIRenderer.cpp.udiff.html You can fix that with or without an updated webrev. Good to clear a class of warnings. -phil. On 06/05/2018 12:47 AM, Baesken, Matthias wrote: Hi Christoph, thank's for the review . Could I have a second one for example from the awt or build-dev reviewers ? Best Regards, Matthias -Original Message- From: Langer, Christoph Sent: Montag, 4. Juni 2018 16:49 To: Baesken, Matthias ; Thomas Stüfe ; 'build-dev@openjdk.java.net' ; awt-...@openjdk.java.net Cc: 2d-dev <2d-...@openjdk.java.net> Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc Hi Matthias, looks good to me. Don't forget the Copyright years. Best regards Christoph -Original Message- From: Baesken, Matthias Sent: Montag, 4. Juni 2018 16:20 To: Thomas Stüfe ; 'build- d...@openjdk.java.net' ; awt- d...@openjdk.java.net Cc: 2d-dev <2d-...@openjdk.java.net>; Langer, Christoph Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc Hello, I prepared a second webrev. - use now const-reference in the catch-statements as suggested by Thomas - reenabled the cl warning showing the exception issues in make/lib/Awt2dLibraries.gmk - found a second place in WPrinterJob.cpp with similar issues after reenabling the warnings Please review : http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/ (cc-ing build-dev because of the makefile change, and src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp because of the awt change ) Thanks, Matthias -Original Message- From: Baesken, Matthias Sent: Montag, 4. Juni 2018 09:24 To: 'Thomas Stüfe' Cc: '2d-dev' <2d-...@openjdk.java.net>; Langer, Christoph Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc A small update - I found a second place in WPrinterJob.cpp where the exception handling is missing. After fixing both places I can reenable warning 4297 in Awt2dLibraries.gmk which has been disabled before , probably because of the warnings generated when the exceptions where not handled . Should I update the change with the other file + makefile change ? Best regards, Matthias hg diff diff -r 12fe57c319e1 make/lib/Awt2dLibraries.gmk --- a/make/lib/Awt2dLibraries.gmk Tue Apr 10 11:02:09 2018 +0800 +++ b/make/lib/Awt2dLibraries.gmk Mon Jun 04 09:18:03 2018 +0200 @@ -213,6 +213,7 @@ LIBAWT_CFLAGS += -fgcse-after-reload endif $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ NAME := awt, \ SRC := $(LIBAWT_DIRS), \ @@ -224,7 +225,7 @@ format-nonliteral parentheses, \ DISABLED_WARNINGS_clang := logical-op-parentheses extern- initializer, \ DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE, \ -DISABLED_WARNINGS_microsoft := 4297 4244 4267 4996, \ +DISABLED_WARNINGS_microsoft := 4244 4267 4996, \ ASFLAGS := $(LIBAWT_ASFLAGS), \ LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \ diff -r 12fe57c319e1 src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp --- a/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c ppTue Apr 10 11:02:09 2018 +0800 +++ b/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c ppMon Jun 04 09:18:03 2018 +0200 @@ -85,7 +85,13 @@ *pNpoints = outpoints; } if (outpoints > POLYTEMPSIZE) { -pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); +try { +pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); +} catch (const std::bad_alloc&) { +return NULL; +} } BOOL isempty = fixend; for (int i = 0; i < npoints; i++) { diff -r 12fe57c319e1 src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp --- a/src/java.desktop/windows/native/libawt/wind
Re: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc
I have checked the fix using mach5. On 05/06/2018 12:45, Phil Race wrote: Oh .. can I please ask that you make sure that VS2017 is OK with the re-enabled warning ? I seriously doubt that it has anything new to add over VS2013, but a jdk-submit will tell you if it has .. VS2017 is now the default so a jdk-submit will use that. -phil. On 06/05/2018 12:43 PM, Phil Race wrote: This looks good to me except for what looks like in my browser like missing indentation in http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/src/java.desktop/windows/native/libawt/java2d/windows /GDIRenderer.cpp.udiff.html You can fix that with or without an updated webrev. Good to clear a class of warnings. -phil. On 06/05/2018 12:47 AM, Baesken, Matthias wrote: Hi Christoph, thank's for the review . Could I have a second one for example from the awt or build-dev reviewers ? Best Regards, Matthias -Original Message- From: Langer, Christoph Sent: Montag, 4. Juni 2018 16:49 To: Baesken, Matthias ; Thomas Stüfe ; 'build-dev@openjdk.java.net' ; awt-...@openjdk.java.net Cc: 2d-dev <2d-...@openjdk.java.net> Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc Hi Matthias, looks good to me. Don't forget the Copyright years. Best regards Christoph -Original Message- From: Baesken, Matthias Sent: Montag, 4. Juni 2018 16:20 To: Thomas Stüfe ; 'build- d...@openjdk.java.net' ; awt- d...@openjdk.java.net Cc: 2d-dev <2d-...@openjdk.java.net>; Langer, Christoph Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc Hello, I prepared a second webrev. - use now const-reference in the catch-statements as suggested by Thomas - reenabled the cl warning showing the exception issues in make/lib/Awt2dLibraries.gmk - found a second place in WPrinterJob.cpp with similar issues after reenabling the warnings Please review : http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/ (cc-ing build-dev because of the makefile change, and src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp because of the awt change ) Thanks, Matthias -Original Message- From: Baesken, Matthias Sent: Montag, 4. Juni 2018 09:24 To: 'Thomas Stüfe' Cc: '2d-dev' <2d-...@openjdk.java.net>; Langer, Christoph Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc A small update - I found a second place in WPrinterJob.cpp where the exception handling is missing. After fixing both places I can reenable warning 4297 in Awt2dLibraries.gmk which has been disabled before , probably because of the warnings generated when the exceptions where not handled . Should I update the change with the other file + makefile change ? Best regards, Matthias hg diff diff -r 12fe57c319e1 make/lib/Awt2dLibraries.gmk --- a/make/lib/Awt2dLibraries.gmk Tue Apr 10 11:02:09 2018 +0800 +++ b/make/lib/Awt2dLibraries.gmk Mon Jun 04 09:18:03 2018 +0200 @@ -213,6 +213,7 @@ LIBAWT_CFLAGS += -fgcse-after-reload endif $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ NAME := awt, \ SRC := $(LIBAWT_DIRS), \ @@ -224,7 +225,7 @@ format-nonliteral parentheses, \ DISABLED_WARNINGS_clang := logical-op-parentheses extern- initializer, \ DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE, \ - DISABLED_WARNINGS_microsoft := 4297 4244 4267 4996, \ + DISABLED_WARNINGS_microsoft := 4244 4267 4996, \ ASFLAGS := $(LIBAWT_ASFLAGS), \ LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \ diff -r 12fe57c319e1 src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp --- a/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c pp Tue Apr 10 11:02:09 2018 +0800 +++ b/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c pp Mon Jun 04 09:18:03 2018 +0200 @@ -85,7 +85,13 @@ *pNpoints = outpoints; } if (outpoints > POLYTEMPSIZE) { - pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); + try { + pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); + } catch (const std::bad_alloc&) { + return NULL; + } } BOOL isempty = fixend; for (int i = 0; i < npoints; i++) { diff -r 12fe57c319e1 src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp --- a/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp Tue Apr 10 11:02:09 2018 +0800 +++ b/src/java.desktop/windows/native/libawt/windows/WPrinterJob.c
Re: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc
Looks fine. On 05/06/2018 09:05, Erik Joelsson wrote: Build change looks ok, but the validity of disabling the warning needs review from someone else. /Erik On 2018-06-05 00:47, Baesken, Matthias wrote: Hi Christoph, thank's for the review . Could I have a second one for example from the awt or build-dev reviewers ? Best Regards, Matthias -Original Message- From: Langer, Christoph Sent: Montag, 4. Juni 2018 16:49 To: Baesken, Matthias ; Thomas Stüfe ; 'build-dev@openjdk.java.net' ; awt-...@openjdk.java.net Cc: 2d-dev <2d-...@openjdk.java.net> Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc Hi Matthias, looks good to me. Don't forget the Copyright years. Best regards Christoph -Original Message- From: Baesken, Matthias Sent: Montag, 4. Juni 2018 16:20 To: Thomas Stüfe ; 'build- d...@openjdk.java.net' ; awt- d...@openjdk.java.net Cc: 2d-dev <2d-...@openjdk.java.net>; Langer, Christoph Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc Hello, I prepared a second webrev. - use now const-reference in the catch-statements as suggested by Thomas - reenabled the cl warning showing the exception issues in make/lib/Awt2dLibraries.gmk - found a second place in WPrinterJob.cpp with similar issues after reenabling the warnings Please review : http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/ (cc-ing build-dev because of the makefile change, and src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp because of the awt change ) Thanks, Matthias -Original Message- From: Baesken, Matthias Sent: Montag, 4. Juni 2018 09:24 To: 'Thomas Stüfe' Cc: '2d-dev' <2d-...@openjdk.java.net>; Langer, Christoph Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc A small update - I found a second place in WPrinterJob.cpp where the exception handling is missing. After fixing both places I can reenable warning 4297 in Awt2dLibraries.gmk which has been disabled before , probably because of the warnings generated when the exceptions where not handled . Should I update the change with the other file + makefile change ? Best regards, Matthias hg diff diff -r 12fe57c319e1 make/lib/Awt2dLibraries.gmk --- a/make/lib/Awt2dLibraries.gmk Tue Apr 10 11:02:09 2018 +0800 +++ b/make/lib/Awt2dLibraries.gmk Mon Jun 04 09:18:03 2018 +0200 @@ -213,6 +213,7 @@ LIBAWT_CFLAGS += -fgcse-after-reload endif $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ NAME := awt, \ SRC := $(LIBAWT_DIRS), \ @@ -224,7 +225,7 @@ format-nonliteral parentheses, \ DISABLED_WARNINGS_clang := logical-op-parentheses extern- initializer, \ DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE, \ - DISABLED_WARNINGS_microsoft := 4297 4244 4267 4996, \ + DISABLED_WARNINGS_microsoft := 4244 4267 4996, \ ASFLAGS := $(LIBAWT_ASFLAGS), \ LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \ diff -r 12fe57c319e1 src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp --- a/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c pp Tue Apr 10 11:02:09 2018 +0800 +++ b/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c pp Mon Jun 04 09:18:03 2018 +0200 @@ -85,7 +85,13 @@ *pNpoints = outpoints; } if (outpoints > POLYTEMPSIZE) { - pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); + try { + pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); + } catch (const std::bad_alloc&) { + return NULL; + } } BOOL isempty = fixend; for (int i = 0; i < npoints; i++) { diff -r 12fe57c319e1 src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp --- a/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp Tue Apr 10 11:02:09 2018 +0800 +++ b/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp Mon Jun 04 09:18:03 2018 +0200 @@ -873,7 +873,12 @@ int numSizes = ::DeviceCapabilities(printerName, printerPort, DC_PAPERS, NULL, NULL); if (numSizes > 0) { - LPTSTR papers = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, numSizes, sizeof(WORD)); + LPTSTR papers; + try { + papers = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, numSizes, sizeof(WORD)); + } catch (const std::bad_alloc&) { + papers = NULL; +
Re: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc
Oh .. can I please ask that you make sure that VS2017 is OK with the re-enabled warning ? I seriously doubt that it has anything new to add over VS2013, but a jdk-submit will tell you if it has .. VS2017 is now the default so a jdk-submit will use that. -phil. On 06/05/2018 12:43 PM, Phil Race wrote: This looks good to me except for what looks like in my browser like missing indentation in http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/src/java.desktop/windows/native/libawt/java2d/windows /GDIRenderer.cpp.udiff.html You can fix that with or without an updated webrev. Good to clear a class of warnings. -phil. On 06/05/2018 12:47 AM, Baesken, Matthias wrote: Hi Christoph, thank's for the review . Could I have a second one for example from the awt or build-dev reviewers ? Best Regards, Matthias -Original Message- From: Langer, Christoph Sent: Montag, 4. Juni 2018 16:49 To: Baesken, Matthias ; Thomas Stüfe ; 'build-dev@openjdk.java.net' ; awt-...@openjdk.java.net Cc: 2d-dev <2d-...@openjdk.java.net> Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc Hi Matthias, looks good to me. Don't forget the Copyright years. Best regards Christoph -Original Message- From: Baesken, Matthias Sent: Montag, 4. Juni 2018 16:20 To: Thomas Stüfe ; 'build- d...@openjdk.java.net' ; awt- d...@openjdk.java.net Cc: 2d-dev <2d-...@openjdk.java.net>; Langer, Christoph Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc Hello, I prepared a second webrev. - use now const-reference in the catch-statements as suggested by Thomas - reenabled the cl warning showing the exception issues in make/lib/Awt2dLibraries.gmk - found a second place in WPrinterJob.cpp with similar issues after reenabling the warnings Please review : http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/ (cc-ing build-dev because of the makefile change, and src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp because of the awt change ) Thanks, Matthias -Original Message- From: Baesken, Matthias Sent: Montag, 4. Juni 2018 09:24 To: 'Thomas Stüfe' Cc: '2d-dev' <2d-...@openjdk.java.net>; Langer, Christoph Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc A small update - I found a second place in WPrinterJob.cpp where the exception handling is missing. After fixing both places I can reenable warning 4297 in Awt2dLibraries.gmk which has been disabled before , probably because of the warnings generated when the exceptions where not handled . Should I update the change with the other file + makefile change ? Best regards, Matthias hg diff diff -r 12fe57c319e1 make/lib/Awt2dLibraries.gmk --- a/make/lib/Awt2dLibraries.gmk Tue Apr 10 11:02:09 2018 +0800 +++ b/make/lib/Awt2dLibraries.gmk Mon Jun 04 09:18:03 2018 +0200 @@ -213,6 +213,7 @@ LIBAWT_CFLAGS += -fgcse-after-reload endif $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ NAME := awt, \ SRC := $(LIBAWT_DIRS), \ @@ -224,7 +225,7 @@ format-nonliteral parentheses, \ DISABLED_WARNINGS_clang := logical-op-parentheses extern- initializer, \ DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE, \ -DISABLED_WARNINGS_microsoft := 4297 4244 4267 4996, \ +DISABLED_WARNINGS_microsoft := 4244 4267 4996, \ ASFLAGS := $(LIBAWT_ASFLAGS), \ LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \ diff -r 12fe57c319e1 src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp --- a/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c ppTue Apr 10 11:02:09 2018 +0800 +++ b/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c ppMon Jun 04 09:18:03 2018 +0200 @@ -85,7 +85,13 @@ *pNpoints = outpoints; } if (outpoints > POLYTEMPSIZE) { -pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); +try { +pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); +} catch (const std::bad_alloc&) { +return NULL; +} } BOOL isempty = fixend; for (int i = 0; i < npoints; i++) { diff -r 12fe57c319e1 src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp --- a/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp Tue Apr 10 11:02:09 2018 +0800 +++ b/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp Mon Jun 04 09:18:03 2018 +0200 @@ -873,7 +873,12 @@ int num
Re: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc
This looks good to me except for what looks like in my browser like missing indentation in http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/src/java.desktop/windows/native/libawt/java2d/windows /GDIRenderer.cpp.udiff.html You can fix that with or without an updated webrev. Good to clear a class of warnings. -phil. On 06/05/2018 12:47 AM, Baesken, Matthias wrote: Hi Christoph, thank's for the review . Could I have a second one for example from the awt or build-dev reviewers ? Best Regards, Matthias -Original Message- From: Langer, Christoph Sent: Montag, 4. Juni 2018 16:49 To: Baesken, Matthias ; Thomas Stüfe ; 'build-dev@openjdk.java.net' ; awt-...@openjdk.java.net Cc: 2d-dev <2d-...@openjdk.java.net> Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc Hi Matthias, looks good to me. Don't forget the Copyright years. Best regards Christoph -Original Message- From: Baesken, Matthias Sent: Montag, 4. Juni 2018 16:20 To: Thomas Stüfe ; 'build- d...@openjdk.java.net' ; awt- d...@openjdk.java.net Cc: 2d-dev <2d-...@openjdk.java.net>; Langer, Christoph Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc Hello, I prepared a second webrev. - use now const-reference in the catch-statements as suggested by Thomas - reenabled the cl warning showing the exception issues in make/lib/Awt2dLibraries.gmk - found a second place in WPrinterJob.cpp with similar issues after reenabling the warnings Please review : http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/ (cc-ing build-dev because of the makefile change, and src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp because of the awt change ) Thanks, Matthias -Original Message- From: Baesken, Matthias Sent: Montag, 4. Juni 2018 09:24 To: 'Thomas Stüfe' Cc: '2d-dev' <2d-...@openjdk.java.net>; Langer, Christoph Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc A small update - I found a second place in WPrinterJob.cpp where the exception handling is missing. After fixing both places I can reenable warning 4297 in Awt2dLibraries.gmk which has been disabled before , probably because of the warnings generated when the exceptions where not handled . Should I update the change with the other file + makefile change ? Best regards, Matthias hg diff diff -r 12fe57c319e1 make/lib/Awt2dLibraries.gmk --- a/make/lib/Awt2dLibraries.gmk Tue Apr 10 11:02:09 2018 +0800 +++ b/make/lib/Awt2dLibraries.gmk Mon Jun 04 09:18:03 2018 +0200 @@ -213,6 +213,7 @@ LIBAWT_CFLAGS += -fgcse-after-reload endif $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ NAME := awt, \ SRC := $(LIBAWT_DIRS), \ @@ -224,7 +225,7 @@ format-nonliteral parentheses, \ DISABLED_WARNINGS_clang := logical-op-parentheses extern- initializer, \ DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE, \ -DISABLED_WARNINGS_microsoft := 4297 4244 4267 4996, \ +DISABLED_WARNINGS_microsoft := 4244 4267 4996, \ ASFLAGS := $(LIBAWT_ASFLAGS), \ LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \ diff -r 12fe57c319e1 src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp --- a/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c ppTue Apr 10 11:02:09 2018 +0800 +++ b/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c ppMon Jun 04 09:18:03 2018 +0200 @@ -85,7 +85,13 @@ *pNpoints = outpoints; } if (outpoints > POLYTEMPSIZE) { -pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); +try { +pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); +} catch (const std::bad_alloc&) { +return NULL; +} } BOOL isempty = fixend; for (int i = 0; i < npoints; i++) { diff -r 12fe57c319e1 src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp --- a/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp Tue Apr 10 11:02:09 2018 +0800 +++ b/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp Mon Jun 04 09:18:03 2018 +0200 @@ -873,7 +873,12 @@ int numSizes = ::DeviceCapabilities(printerName, printerPort, DC_PAPERS, NULL, NULL); if (numSizes > 0) { - LPTSTR papers = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, numSizes, sizeof(WORD)); + LPTSTR papers; + try { + papers
Re: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc
Build change looks ok, but the validity of disabling the warning needs review from someone else. /Erik On 2018-06-05 00:47, Baesken, Matthias wrote: Hi Christoph, thank's for the review . Could I have a second one for example from the awt or build-dev reviewers ? Best Regards, Matthias -Original Message- From: Langer, Christoph Sent: Montag, 4. Juni 2018 16:49 To: Baesken, Matthias ; Thomas Stüfe ; 'build-dev@openjdk.java.net' ; awt-...@openjdk.java.net Cc: 2d-dev <2d-...@openjdk.java.net> Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc Hi Matthias, looks good to me. Don't forget the Copyright years. Best regards Christoph -Original Message- From: Baesken, Matthias Sent: Montag, 4. Juni 2018 16:20 To: Thomas Stüfe ; 'build- d...@openjdk.java.net' ; awt- d...@openjdk.java.net Cc: 2d-dev <2d-...@openjdk.java.net>; Langer, Christoph Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc Hello, I prepared a second webrev. - use now const-reference in the catch-statements as suggested by Thomas - reenabled the cl warning showing the exception issues in make/lib/Awt2dLibraries.gmk - found a second place in WPrinterJob.cpp with similar issues after reenabling the warnings Please review : http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/ (cc-ing build-dev because of the makefile change, and src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp because of the awt change ) Thanks, Matthias -Original Message- From: Baesken, Matthias Sent: Montag, 4. Juni 2018 09:24 To: 'Thomas Stüfe' Cc: '2d-dev' <2d-...@openjdk.java.net>; Langer, Christoph Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc A small update - I found a second place in WPrinterJob.cpp where the exception handling is missing. After fixing both places I can reenable warning 4297 in Awt2dLibraries.gmk which has been disabled before , probably because of the warnings generated when the exceptions where not handled . Should I update the change with the other file + makefile change ? Best regards, Matthias hg diff diff -r 12fe57c319e1 make/lib/Awt2dLibraries.gmk --- a/make/lib/Awt2dLibraries.gmk Tue Apr 10 11:02:09 2018 +0800 +++ b/make/lib/Awt2dLibraries.gmk Mon Jun 04 09:18:03 2018 +0200 @@ -213,6 +213,7 @@ LIBAWT_CFLAGS += -fgcse-after-reload endif $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ NAME := awt, \ SRC := $(LIBAWT_DIRS), \ @@ -224,7 +225,7 @@ format-nonliteral parentheses, \ DISABLED_WARNINGS_clang := logical-op-parentheses extern- initializer, \ DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE, \ -DISABLED_WARNINGS_microsoft := 4297 4244 4267 4996, \ +DISABLED_WARNINGS_microsoft := 4244 4267 4996, \ ASFLAGS := $(LIBAWT_ASFLAGS), \ LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \ diff -r 12fe57c319e1 src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp --- a/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c ppTue Apr 10 11:02:09 2018 +0800 +++ b/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c ppMon Jun 04 09:18:03 2018 +0200 @@ -85,7 +85,13 @@ *pNpoints = outpoints; } if (outpoints > POLYTEMPSIZE) { -pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); +try { +pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); +} catch (const std::bad_alloc&) { +return NULL; +} } BOOL isempty = fixend; for (int i = 0; i < npoints; i++) { diff -r 12fe57c319e1 src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp --- a/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp Tue Apr 10 11:02:09 2018 +0800 +++ b/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp Mon Jun 04 09:18:03 2018 +0200 @@ -873,7 +873,12 @@ int numSizes = ::DeviceCapabilities(printerName, printerPort, DC_PAPERS, NULL, NULL); if (numSizes > 0) { - LPTSTR papers = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, numSizes, sizeof(WORD)); + LPTSTR papers; + try { + papers = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, numSizes, sizeof(WORD)); + } catch (const std::bad_alloc&) { + papers = NULL; + } if (papers != NULL && ::
RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc
Hi Christoph, thank's for the review . Could I have a second one for example from the awt or build-dev reviewers ? Best Regards, Matthias > -Original Message- > From: Langer, Christoph > Sent: Montag, 4. Juni 2018 16:49 > To: Baesken, Matthias ; Thomas Stüfe > ; 'build-dev@openjdk.java.net' d...@openjdk.java.net>; awt-...@openjdk.java.net > Cc: 2d-dev <2d-...@openjdk.java.net> > Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in > GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using > SAFE_SIZE_ARRAY_ALLOC / safe_Malloc > > Hi Matthias, > > looks good to me. > > Don't forget the Copyright years. > > Best regards > Christoph > > > -Original Message- > > From: Baesken, Matthias > > Sent: Montag, 4. Juni 2018 16:20 > > To: Thomas Stüfe ; 'build- > > d...@openjdk.java.net' ; awt- > > d...@openjdk.java.net > > Cc: 2d-dev <2d-...@openjdk.java.net>; Langer, Christoph > > > > Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in > > GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using > > SAFE_SIZE_ARRAY_ALLOC / safe_Malloc > > > > Hello, I prepared a second webrev. > > > > - use now const-reference in the catch-statements as suggested by > Thomas > > - reenabled the cl warning showing the exception issues in > > make/lib/Awt2dLibraries.gmk > > - found a second place in WPrinterJob.cpp with similar issues after > > reenabling the warnings > > > > Please review : > > > > http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/ > > > > (cc-ing build-dev because of the makefile change, and > > src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp > > because of the awt change ) > > > > > > Thanks, Matthias > > > > > > > > > -Original Message----- > > > From: Baesken, Matthias > > > Sent: Montag, 4. Juni 2018 09:24 > > > To: 'Thomas Stüfe' > > > Cc: '2d-dev' <2d-...@openjdk.java.net>; Langer, Christoph > > > > > > Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception > in > > > GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using > > > SAFE_SIZE_ARRAY_ALLOC / safe_Malloc > > > > > > A small update - I found a second place in WPrinterJob.cpp where > > > the > > > exception handling is missing. After fixing both places I can reenable > > > warning 4297 in > > > Awt2dLibraries.gmk which has been disabled before , probably > because > > of > > > the warnings generated when the exceptions where not handled . > > > Should I update the change with the other file + makefile change ? > > > > > > Best regards, Matthias > > > > > > > > > >hg diff > > > diff -r 12fe57c319e1 make/lib/Awt2dLibraries.gmk > > > --- a/make/lib/Awt2dLibraries.gmk Tue Apr 10 11:02:09 2018 +0800 > > > +++ b/make/lib/Awt2dLibraries.gmk Mon Jun 04 09:18:03 2018 +0200 > > > @@ -213,6 +213,7 @@ > > >LIBAWT_CFLAGS += -fgcse-after-reload > > > endif > > > > > > > > > $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ > > > NAME := awt, \ > > > SRC := $(LIBAWT_DIRS), \ > > > @@ -224,7 +225,7 @@ > > > format-nonliteral parentheses, \ > > > DISABLED_WARNINGS_clang := logical-op-parentheses extern- > initializer, > > \ > > > DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE, \ > > > -DISABLED_WARNINGS_microsoft := 4297 4244 4267 4996, \ > > > +DISABLED_WARNINGS_microsoft := 4244 4267 4996, \ > > > ASFLAGS := $(LIBAWT_ASFLAGS), \ > > > LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), > \ > > > LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \ > > > diff -r 12fe57c319e1 > > > > > > src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp > > > --- > > > > > > a/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c > > > ppTue Apr 10 11:02:09 2018 +0800 > > > +++ > > > > > > b/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c > > > ppMon Jun 04 09:18:03 2018 +0200 > > > @@ -85,7 +85,13 @@ > > > *pNpoints = outpoints; > > > } > > > if (outpoints > POLYTEMPSIZE) { > > > -pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, > > >
RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc
Hi Matthias, looks good to me. Don't forget the Copyright years. Best regards Christoph > -Original Message- > From: Baesken, Matthias > Sent: Montag, 4. Juni 2018 16:20 > To: Thomas Stüfe ; 'build- > d...@openjdk.java.net' ; awt- > d...@openjdk.java.net > Cc: 2d-dev <2d-...@openjdk.java.net>; Langer, Christoph > > Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in > GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using > SAFE_SIZE_ARRAY_ALLOC / safe_Malloc > > Hello, I prepared a second webrev. > > - use now const-reference in the catch-statements as suggested by Thomas > - reenabled the cl warning showing the exception issues in > make/lib/Awt2dLibraries.gmk > - found a second place in WPrinterJob.cpp with similar issues after > reenabling the warnings > > Please review : > > http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/ > > (cc-ing build-dev because of the makefile change, and > src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp > because of the awt change ) > > > Thanks, Matthias > > > > > -Original Message- > > From: Baesken, Matthias > > Sent: Montag, 4. Juni 2018 09:24 > > To: 'Thomas Stüfe' > > Cc: '2d-dev' <2d-...@openjdk.java.net>; Langer, Christoph > > > > Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in > > GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using > > SAFE_SIZE_ARRAY_ALLOC / safe_Malloc > > > > A small update - I found a second place in WPrinterJob.cpp where the > > exception handling is missing. After fixing both places I can reenable > > warning 4297 in > > Awt2dLibraries.gmk which has been disabled before , probably because > of > > the warnings generated when the exceptions where not handled . > > Should I update the change with the other file + makefile change ? > > > > Best regards, Matthias > > > > > > >hg diff > > diff -r 12fe57c319e1 make/lib/Awt2dLibraries.gmk > > --- a/make/lib/Awt2dLibraries.gmk Tue Apr 10 11:02:09 2018 +0800 > > +++ b/make/lib/Awt2dLibraries.gmk Mon Jun 04 09:18:03 2018 +0200 > > @@ -213,6 +213,7 @@ > >LIBAWT_CFLAGS += -fgcse-after-reload > > endif > > > > > > $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ > > NAME := awt, \ > > SRC := $(LIBAWT_DIRS), \ > > @@ -224,7 +225,7 @@ > > format-nonliteral parentheses, \ > > DISABLED_WARNINGS_clang := logical-op-parentheses extern-initializer, > \ > > DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE, \ > > -DISABLED_WARNINGS_microsoft := 4297 4244 4267 4996, \ > > +DISABLED_WARNINGS_microsoft := 4244 4267 4996, \ > > ASFLAGS := $(LIBAWT_ASFLAGS), \ > > LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \ > > LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \ > > diff -r 12fe57c319e1 > > > src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp > > --- > > > a/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c > > ppTue Apr 10 11:02:09 2018 +0800 > > +++ > > > b/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c > > ppMon Jun 04 09:18:03 2018 +0200 > > @@ -85,7 +85,13 @@ > > *pNpoints = outpoints; > > } > > if (outpoints > POLYTEMPSIZE) { > > -pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, > > sizeof(POINT), outpoints); > > +try { > > +pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, > > sizeof(POINT), outpoints); > > +} catch (const std::bad_alloc&) { > > +return NULL; > > +} > > } > > BOOL isempty = fixend; > > for (int i = 0; i < npoints; i++) { > > diff -r 12fe57c319e1 > > src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp > > --- a/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp > > Tue Apr 10 11:02:09 2018 +0800 > > +++ > b/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp > > Mon Jun 04 09:18:03 2018 +0200 > > @@ -873,7 +873,12 @@ > >int numSizes = ::DeviceCapabilities(printerName, printerPort, > >DC_PAPERS, NULL, NULL); > >if (numSizes > 0) { > > - LPTSTR papers = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, > > numSizes, sizeof(WORD)); > > + LPTSTR papers; > > + try { > > +
RE: RFR: JDK-8204211: windows : handle potential C++ exception in GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using SAFE_SIZE_ARRAY_ALLOC / safe_Malloc
Hello, I prepared a second webrev. - use now const-reference in the catch-statements as suggested by Thomas - reenabled the cl warning showing the exception issues in make/lib/Awt2dLibraries.gmk - found a second place in WPrinterJob.cpp with similar issues after reenabling the warnings Please review : http://cr.openjdk.java.net/~mbaesken/webrevs/8204211.1/ (cc-ing build-dev because of the makefile change, and src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp because of the awt change ) Thanks, Matthias > -Original Message- > From: Baesken, Matthias > Sent: Montag, 4. Juni 2018 09:24 > To: 'Thomas Stüfe' > Cc: '2d-dev' <2d-...@openjdk.java.net>; Langer, Christoph > > Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in > GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using > SAFE_SIZE_ARRAY_ALLOC / safe_Malloc > > A small update - I found a second place in WPrinterJob.cpp where the > exception handling is missing. After fixing both places I can reenable > warning 4297 in > Awt2dLibraries.gmk which has been disabled before , probably because of > the warnings generated when the exceptions where not handled . > Should I update the change with the other file + makefile change ? > > Best regards, Matthias > > > >hg diff > diff -r 12fe57c319e1 make/lib/Awt2dLibraries.gmk > --- a/make/lib/Awt2dLibraries.gmk Tue Apr 10 11:02:09 2018 +0800 > +++ b/make/lib/Awt2dLibraries.gmk Mon Jun 04 09:18:03 2018 +0200 > @@ -213,6 +213,7 @@ >LIBAWT_CFLAGS += -fgcse-after-reload > endif > > > $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ > NAME := awt, \ > SRC := $(LIBAWT_DIRS), \ > @@ -224,7 +225,7 @@ > format-nonliteral parentheses, \ > DISABLED_WARNINGS_clang := logical-op-parentheses extern-initializer, \ > DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE, \ > -DISABLED_WARNINGS_microsoft := 4297 4244 4267 4996, \ > +DISABLED_WARNINGS_microsoft := 4244 4267 4996, \ > ASFLAGS := $(LIBAWT_ASFLAGS), \ > LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \ > LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \ > diff -r 12fe57c319e1 > src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp > --- > a/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c > ppTue Apr 10 11:02:09 2018 +0800 > +++ > b/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.c > ppMon Jun 04 09:18:03 2018 +0200 > @@ -85,7 +85,13 @@ > *pNpoints = outpoints; > } > if (outpoints > POLYTEMPSIZE) { > -pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, > sizeof(POINT), outpoints); > +try { > +pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, > sizeof(POINT), outpoints); > +} catch (const std::bad_alloc&) { > +return NULL; > +} > } > BOOL isempty = fixend; > for (int i = 0; i < npoints; i++) { > diff -r 12fe57c319e1 > src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp > --- a/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp > Tue Apr 10 11:02:09 2018 +0800 > +++ b/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp > Mon Jun 04 09:18:03 2018 +0200 > @@ -873,7 +873,12 @@ >int numSizes = ::DeviceCapabilities(printerName, printerPort, >DC_PAPERS, NULL, NULL); >if (numSizes > 0) { > - LPTSTR papers = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, > numSizes, sizeof(WORD)); > + LPTSTR papers; > + try { > + papers = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, numSizes, > sizeof(WORD)); > + } catch (const std::bad_alloc&) { > + papers = NULL; > + } >if (papers != NULL && >::DeviceCapabilities(printerName, printerPort, > DC_PAPERS, papers, NULL) != -1) { > > > > > > > > -----Original Message- > > From: Baesken, Matthias > > Sent: Freitag, 1. Juni 2018 14:18 > > To: 'Thomas Stüfe' > > Cc: 2d-dev <2d-...@openjdk.java.net>; Langer, Christoph > > > > Subject: RE: RFR: JDK-8204211: windows : handle potential C++ exception in > > GDIRenderer -was : RE: [OpenJDK 2D-Dev] java2d coding using > > SAFE_SIZE_ARRAY_ALLOC / safe_Malloc > > > > Hi Thomas , using the const-reference sounds like a good idea ( I just > > copied from other locations in the source code where (almost?) always > > std::bad_alloc& (non