RFR: 8339460: CDS error when module is located in a directory with space in the name
Maxim Kartashev
mkartashev at openjdk.org
Mon Sep 16 10:23:08 UTC 2024
On Fri, 13 Sep 2024 08:04:58 GMT, Maxim Kartashev <mkartashev at openjdk.org> wrote:
> The crux of the problem is that path names in CDS are saved as URIs and subsequently "converted" back to path names simply by stripping off the prefix without appropriate conversion of the rest of the name. This commit adds such a conversion.
The URI is coming from the Java side. When a module is defined, its location is kept as a URI. See `Modules.java`:
Module defineModule(ClassLoader loader, ModuleDescriptor descriptor, URI uri);
Later on, the URI is converted into a path name, see `ClassLoaderExt::process_module_table()`:
path = ClassLoader::skip_uri_protocol(path);
char* path_copy = NEW_RESOURCE_ARRAY(char, strlen(path) + 1);
strcpy(path_copy, path);
_module_paths->append(path_copy);
That path name, untouched, is passed to `os::stat()` to verify the file; see `ClassLoader::setup_module_search_path()`:
if (os::stat(path, &st) != 0) {
tty->print_cr("os::stat error %d (%s). CDS dump aborted (path was "%s").",
errno, os::errno_name(errno), path);
vm_exit_during_initialization();
}
At this point, if the original URI had any escaped characters, `os::stat()` would fail terminating the entire JVM.
There are other code paths that also had to be fixed.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20987#issuecomment-2352523476
More information about the hotspot-runtime-dev
mailing list