Instance initialization failed

When attempting to create an instance with vkCreateInstance, a VK_ERROR_INITIALIZATION_FAILED code is returned via the instance debug messenger as a warning (not from vkCreateInstance itself). I’m also experiencing crashes in native code, which seems to be connected, but I’m not sure.

As a heads up, I’m using Java with LWJGL3 for native binding, and there are a lot of little utility methods I use to make pointers and such easier to work with.

public void initApplication() {
    layers.add("VK_LAYER_KHRONOS_validation");
    try (MemoryStack stack = MemoryStack.stackPush()) {
        PointerBuffer layerPtrs = createLayerBuffer(stack, layers);
        LOG.info("Validation layers: " + layers.size() + ", buffer: " + layerPtrs);
        createInstance(stack, layerPtrs);
        if (layerPtrs != null) {
            createDebugMessenger(stack);
        }
        PhysicalDevice physDevice = findPhysicalDevice(stack, instance);
        QueueFamilyIndices queues = populateQueueFamily(stack, physDevice.getDevice());
        device = createLogicalDevice(stack, physDevice, queues, layerPtrs);
        graphics = getQueue(stack, device, queues, 0);
    }
}

private void createInstance(MemoryStack stack, PointerBuffer layers) {
    VkApplicationInfo app = VkApplicationInfo.calloc(stack)
            .sType(VK_STRUCTURE_TYPE_APPLICATION_INFO)
            .pApplicationName(stack.ASCII(context.getSettings().getTitle()))
            .applicationVersion(VK_MAKE_VERSION(1, 0, 0))
            .pEngineName(stack.ASCII("JMonkeyEngine"))
            .engineVersion(VK_MAKE_VERSION(3, 9, 0))
            .apiVersion(VK_API_VERSION_1_3);
    VkInstanceCreateInfo create = VkInstanceCreateInfo.calloc(stack)
            .sType(VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO)
            .pApplicationInfo(app);
    addExtension(Objects.requireNonNull(GLFWVulkan.glfwGetRequiredInstanceExtensions()));
    addExtension(stack, VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
    create.ppEnabledExtensionNames(gatherPointers(stack, extensions));
    if (layers != null) {
        create.pNext(createDebugger(stack, debugCallback)); // causing native crashes?
        create.ppEnabledLayerNames(layers);
    }
    instance = new VkInstance(getPointer(stack,
            ptr -> check(vkCreateInstance(create, null, ptr), "Failed to create instance.")), create);
}

private VkDebugUtilsMessengerCreateInfoEXT createDebugger(MemoryStack stack, VkDebugUtilsMessengerCallbackEXT callback) {
    return VkDebugUtilsMessengerCreateInfoEXT.calloc(stack)
            .sType(VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT)
            .messageSeverity(VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT
                    | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT)
            .messageType(VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
                    VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT)
                    .pfnUserCallback(callback);
}
WARNING  terminator_CreateInstance: Received return code -3 from call to vkCreateInstance in ICD /usr/lib/x86_64-linux-gnu/libvulkan_virtio.so. Skipping this driver.

As mentioned before, the error code only comes through the instance debug messenger as a warning, so I’m not sure what to make of it.

Later on, a crash in native code occurs when I attempt to create a logical device with vkCreateDevice. The crash message doesn’t give much to go on, but I managed to locate the crash location using an IDE debugger.

private VkDevice createLogicalDevice(MemoryStack stack, PhysicalDevice device, QueueFamilyIndices fams, PointerBuffer layers) {
    System.out.println("graphics queue: " + fams.graphics);
    VkDeviceQueueCreateInfo.Buffer queueCreate = VkDeviceQueueCreateInfo.calloc(1, stack)
            .sType(VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO)
            .queueFamilyIndex(fams.graphics)
            .pQueuePriorities(stack.floats(1f));
    VkDeviceCreateInfo deviceCreate = VkDeviceCreateInfo.calloc(stack)
            .sType(VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO)
            .pQueueCreateInfos(queueCreate)
            .pEnabledFeatures(device.getFeatures());
    if (layers != null) {
        deviceCreate.ppEnabledLayerNames(layers);
    }
    // crash occurs here
    long devHandle = getPointer(stack, ptr -> check(vkCreateDevice(device.getDevice(), deviceCreate, null, ptr),
            "Failed to create logical device."));
    return new VkDevice(devHandle, device.getDevice(), deviceCreate);
}
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000707c9545933a, pid=6377, tid=6436
#
# JRE version: Java(TM) SE Runtime Environment (23.0.2+7) (build 23.0.2+7-58)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.0.2+7-58, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C  [libjemalloc.so+0x5933a]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /home/codex/java/prj/jmonkeyengine/core.6377)
#
# An error report file with more information is saved as:
# /home/codex/java/prj/jmonkeyengine/hs_err_pid6377.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#

Strangely enough, the crash is “postponed” until the program attempts to exit if I don’t attach a debug messenger to the instance.

Edit: I’m using a Nvidia GeForce GTX 1060.