RFR: 8263136: C4530 was reported from VS 2019 at access bridge

Thomas Stuefe stuefe at openjdk.java.net
Sun Mar 7 19:37:08 UTC 2021


On Sun, 7 Mar 2021 16:19:15 GMT, Phil Race <prr at openjdk.org> wrote:

>> I saw C4530 with VS 2019 (16.9.0) as following (on Japanese locale):
>> 
>> AccessBridgeDebug.cpp
>> メモ: インクルード ファイル: d:\github-forked\jdk\src\jdk.accessibility\windows\native\common\AccessBridgeDebug.h
>> 
>>     :
>> 
>> c:\progra~2\micros~2\2019\commun~1\vc\tools\msvc\1428~1.299\include\ostream(611): error C2220: 次の警
>> 告はエラーとして処理されます
>> c:\progra~2\micros~2\2019\commun~1\vc\tools\msvc\1428~1.299\include\ostream(611): warning C4530: C++
>> 例外処理を使っていますが、アンワインド セマンティクスは有効にはなりません。/EHsc を指定してください。
>> メモ: インクルード ファイル: c:\progra~2\micros~2\2019\commun~1\vc\tools\msvc\1428~1.299\include\string
>> 
>> `/EHsc` has been already passed in other makefiles, and also AccessBridgeDebug.cpp uses some STL classes (e.g. `chrono` namespace). So `/EHsc` is a solution for this problem.
>
> translate.google.com says the error in (almost) English is : 
> c: \ program ~ 2 \ micros ~ 2 \ 2019 \ commun ~ 1 \ vc \ tools \ msvc \ 1428 ~ 1.299 \ include \ ostream (611): warning C4530: C ++ 
> I'm using exception handling, but unwind semantics aren't enabled. Please specify / EHsc.

Yes, including c++ standard library headers like <ostream> means you need to deal with C++ exceptions thrown from library functions, and the code needs to be compiled with unwind capabilities. If its not switched on, and a C++ exception happens, the behavior is undefined. In my experience it results in the process being terminated.

I wondered why C++ std headers are even used. The source code looks C-ish; but "8196681: Java Access Bridge logging and debug flags dynamically controlled" added some coding, adding a bunch of C++11x semantics and included C++ std headers. Using "/Ehsc" had even been discussed: https://mail.openjdk.java.net/pipermail/awt-dev/2018-December/014847.html but not done.

Adding /Ehsc is fine of course, but I think thats not enough. Now C++ exceptions can pass through the code, but if they do, then what? E.g. this function `getTimeStamp()` added with 8196681:

https://github.com/openjdk/jdk/blob/113b5184cfc78fde057a7fe4d5872b463930da00/src/jdk.accessibility/windows/native/common/AccessBridgeDebug.cpp#L85

calls into the C++ standard library to get a time stamp. Can't these function not throw C++ exceptions? Is that not what the compiler is warning about? If they throw, exceptions propagate through the code unbounded, until they either end the process or cause havoc at the next upper C-only-interface.

Or, maybe, rewrite this coding to use standard C- and Windows-APIs.  I think 8196681 could had been done with traditional windows- or standard C APIs. In particular, `getTimeStamp()` could probably be done simply with `GetTickCount` or `GetSystemTime` or functions from time.h.

Cheers, Thomas

-------------

PR: https://git.openjdk.java.net/jdk/pull/2859



More information about the build-dev mailing list