RFR: 8299329: Assertion failure with fastdebug build when trying to use CDS without classpath [v2]

Ashutosh Mehra duke at openjdk.org
Wed Jan 4 17:40:59 UTC 2023


On Wed, 4 Jan 2023 17:31:04 GMT, Ashutosh Mehra <duke at openjdk.org> wrote:

>> It appears longest_common_app_classpath_prefix_len() is not returning correct value when there is no file separator in the path being searched backwards. Instead of returning 0 it return 1.
>> 
>> In case of empty classpath, it can result in assertion failure in check_paths():
>> 
>> `assert(strlen(rp_array->at(i)) > (size_t)runtime_prefix_len, "sanity");`
>> 
>> It can also result in incorrectly validating the app classpaths if they only differ by first character. Eg:
>> 
>> Dump time:
>>   -cp hello.jar
>> Run time:
>>   -cp mello.jar
>> 
>> This would not result in classpath mismatch!
>> 
>> This fix updates longest_common_app_classpath_prefix_len() to return 0 if no file separator character is found.
>> 
>> Signed-off-by: Ashutosh Mehra <asmehra at redhat.com>
>
> Ashutosh Mehra has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Add cds test for mismatch in jar file due to first character only
>    
>    Signed-off-by: Ashutosh Mehra <asmehra at redhat.com>
>  - Fix no-classpath test
>    
>    Signed-off-by: Ashutosh Mehra <asmehra at redhat.com>

Adding `-Djava.class.path=` wouldn't work as it is different than the case when no classpath is specified. When there is no classpath specified, launcher adds "." as the classpath.
To fix the "no-classpath" test I added another system property `test.noclasspath` to avoid setting 'cp' in `ProcessTools#createJavaProcessBuilder`. I realized the CLASSPATH env variable is also set when the test Java process is created, so that needs to be removed as well.

> Also, I think you should add the -cp hello.jar vs -cp mello.jar test case into WrongClasspath.java.

I have added this test as well.

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

PR: https://git.openjdk.org/jdk/pull/11781


More information about the hotspot-runtime-dev mailing list