RFR: 8296812: sprintf is deprecated in Xcode 14 [v19]

Michael Hall mik3hall at gmail.com
Fri Dec 9 20:29:50 UTC 2022



> On Dec 9, 2022, at 11:57 AM, Laurent Bourgès <lbourges at openjdk.org> wrote:
> 
> On Thu, 8 Dec 2022 19:41:16 GMT, Xue-Lei Andrew Fan <xuelei at openjdk.org> wrote:
> 
>>> Hi,
>>> 
>>> May I have this update reviewed?
>>> 
>>> The sprintf is deprecated in Xcode 14 because of security concerns, and the use of it causing building failure.  The build could pass if warnings are disabled for codes that use sprintf method.  For the long run, the sprintf could be replaced with snprintf.  This patch is trying to check if snprintf could be used.
>>> 
>>> Thanks,
>>> Xuelei
>> 
>> Xue-Lei Andrew Fan has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 24 additional commits since the last revision:
>> 
>> - adlc update per review
>> - Merge
>> - update on review feedback
>> - comment for snprintf_checked
>> - use checked snprintf for adlc
>> - use checked snprintf
>> - no check on adlc
>> - revert use of assert
>> - extra sizeof typo
>> - more size_t updare for windows build
>> - ... and 14 more: https://git.openjdk.org/jdk/compare/2309602b...49bb58fd
> 
> LGTM, build on macos 13 + xcode 14.1 (x64): OK
> 
> I run successfully few applications with built jdk image...
> 
> 
> Configuration summary:
> * Name:           macosx-x86_64-server-release
> * Debug level:    release
> * HS debug level: product
> * JVM variants:   server
> * JVM features:   server: 'cds compiler1 compiler2 dtrace epsilongc g1gc jfr jni-check jvmci jvmti management parallelgc serialgc services shenandoahgc vm-structs zgc' 
> * OpenJDK target: OS: macosx, CPU architecture: x86, address length: 64
> * Version string: 20-internal-adhoc.jmmc.jdk-gh (20-internal)
> * Source date:    1670605929 (2022-12-09T17:12:09Z)
> 
> Tools summary:
> * Boot JDK:       openjdk version "20-ea" 2023-03-21 OpenJDK Runtime Environment (build 20-ea+26-2022) OpenJDK 64-Bit Server VM (build 20-ea+26-2022, mixed mode, sharing) (at /Users/jmmc/apps/jdk-20.jdk/Contents/Home)
> * Toolchain:      clang (clang/LLVM from Xcode 14.1)
> * Sysroot:        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk
> * C Compiler:     Version 14.0.0 (at /usr/bin/clang)
> * C++ Compiler:   Version 14.0.0 (at /usr/bin/clang++)
> 
> -------------
> 
> PR: https://git.openjdk.org/jdk/pull/11115

Fwiw, Where I seem to differ…

macOS 12.6 

* Version string: 20-internal-adhoc.mjh.jdk (20-internal)
* Source date:    1668643046 (2022-11-16T23:57:26Z)

* Boot JDK:       openjdk version "19" 2022-09-20 OpenJDK Runtime Environment (build 19+36-2238) OpenJDK 64-Bit Server VM (build 19+36-2238, mixed mode, sharing) (at /Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home)

But it did build without the cmstypes errors.
Attempting tier 1 tests showed an sprintf deprecation error as follows…

=== Output from failing command(s) repeated here ===
* For target support_test_hotspot_jtreg_native_support_libAsyncExceptionOnMonitorEnter_libAsyncExceptionOnMonitorEnter.o:
/Users/mjh/Documents/GitHub/jdk/test/hotspot/jtreg/runtime/Thread/libAsyncExceptionOnMonitorEnter.cpp:37:3: error: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Werror,-Wdeprecated-declarations]
  sprintf(name, "MyRawMonitor");
  ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
__deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.")
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^
1 error generated.







More information about the client-libs-dev mailing list