RFR: 8343802: Prevent NULL usage backsliding
Nizar Benalla
nbenalla at openjdk.org
Wed Feb 5 19:19:12 UTC 2025
On Wed, 5 Feb 2025 17:33:21 GMT, Julian Waters <jwaters at openjdk.org> wrote:
>> Please review this patch to add a test that checks the hotspot sources and test files for usages of NULL.
>> It scans files in those directories, filtering out certain files as well as all `.c`, `.java` and `.jar` files in test sources.
>>
>> Before adding line 86 and excluding `os_windows.cpp`, the test failed with:
>>
>>
>> Error: 'NULL' found in /w/jdk/src/hotspot/os/windows/os_windows.cpp at line 4436:
>> HMODULE hModule = NULL;
>> Error: 'NULL' found in /w/jdk/src/hotspot/os/windows/os_windows.cpp at line 4437:
>> GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, &hModule);
>> java.lang.RuntimeException: Found usage of 'NULL' in source files. See errors above.
>> at TestNoNULL.main(TestNoNULL.java:73)
>> at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
>> at java.base/java.lang.reflect.Method.invoke(Method.java:565)
>> at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:333)
>> at java.base/java.lang.Thread.run(Thread.java:1447)
>
> Seems like this solution would require someone working on the JDK to run the proper test, something which not everyone is guaranteed to do when working on HotSpot. Is there a way to make this part of the build process so trying to compile HotSpot will fail if there are NULLs in the source code?
>
> EDIT: Removed the quoting of the original Pull Request body
@TheShermanTanker I ran GHA in a separate branch and intentionally [triggered a failure](https://productionresultssa0.blob.core.windows.net/actions-results/a48b32b8-8741-4c53-bd4d-791ea6525f8c/workflow-job-run-31d5d6cf-dbfa-5459-b435-eff5465595d4/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-02-05T19%3A23%3A48Z&sig=BDGTWHIHY%2BTGhMPBLnMGqoKOSfZmRQidkoZgQ%2BTwjKA%3D&ske=2025-02-06T04%3A21%3A13Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-02-05T16%3A21%3A13Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2025-01-05&sp=r&spr=https&sr=b&st=2025-02-05T19%3A13%3A43Z&sv=2025-01-05). Use Control Find and look for `Error: 'NULL' found in`.
GHA should fail and alert developers that there is an issue.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23466#issuecomment-2637819950
More information about the hotspot-dev
mailing list