Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layers: Correctly update iterator when erasing vector element #256

Merged

Conversation

robbiesri
Copy link
Contributor

ApiLayerInterface::LoadApiLayers would load the manifest files for explicit layers in order to match them against requested layers. As the layers are matched, they would be erased from the manifest vector in order to prevent double-matching. However, in the erase case, the iterator wasn't being updated correctly.

ApiLayerInterface::LoadApiLayers would load the manifest files for explicit layers in order to match them against requested layers. As the layers are matched, they would be erased from the manifest vector in order to prevent double-matching. However, in the erase case, the iterator wasn't being updated correctly.
@robbiesri
Copy link
Contributor Author

Oh, I forgot about the repro. I hit this while trying to enable the core validation layer with hello_xr. I used the environment variables below (Windows 10 x64, VS 2019):

XR_API_LAYER_PATH=D:\\git\\OpenXR-SDK-Source\\build\\win64\\src\\api_layers
XR_ENABLE_API_LAYERS=XR_APILAYER_LUNARG_core_validation

@rpavlik
Copy link
Contributor

rpavlik commented May 18, 2021

@bradgrantham-lunarg thanks for looking into this. Is there some way we could extend the loader test to test for this? I just checked and the loader test passed fine here as-is (once I disabled the active runtime, at least - that part never seems to work quite right)

@rpavlik
Copy link
Contributor

rpavlik commented May 18, 2021

@robbiesri Would you mind adding a changelog fragment in changes/sdk/ named pr.256.gh.OpenXR-SDK-Source.md to include in the next release changelog?

@bradgrantham-lunarg
Copy link

@bradgrantham-lunarg thanks for looking into this. Is there some way we could extend the loader test to test for this? I just checked and the loader test passed fine here as-is (once I disabled the active runtime, at least - that part never seems to work quite right)

Oh, I don't get any credit for this, Rob just filed it independently. This does now match the idiom cppreference.com reports for vector::erase. :sheepish:

However, If I remember this correctly, the outer loop walks the layers enabled by environment variable or by CreateInstance. The inner loop walks the manifest list to make sure the enabled layer was discovered, and if so it deletes that name from the discovered list so it's ignored if it's in the enabled layer list twice. I mean, that is wrong, and in that case the iterator would have been double-incremented, but I'm wondering what the failure would be in the case that there's just one explicit layer. Crash because iterator was end() and then was incremented restarting the loop body? I thought I had tested the case of one layer but maybe I didn't test properly or was sloppy.

@robbiesri , what is the failure and could you post the output of XR_LOADER_DEBUG=all?

@robbiesri
Copy link
Contributor Author

Hey all!

@robbiesri , what is the failure and could you post the output of XR_LOADER_DEBUG=all?

The failure was indeed iterating past end with the iterator for explicit_layer_manifest_files. In my setup, I had the api_dump and core_validation layers built, and I was trying to enable core_validation when I hit this issue.

Let me get you the dump from XR_LOADER_DEBUG.

@robbiesri Would you mind adding a changelog fragment in changes/sdk/ named pr.256.gh.OpenXR-SDK-Source.md to include in the next release changelog?

Yep, no problem! I'll add that in a minute!

@robbiesri
Copy link
Contributor Author

here's the output from XR_LOADER_DEBUG

Verbose [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : Entering loader trampoline
[10:20:41.725][Info   ] Press any key to shutdown...
Warning [GENERAL |  | OpenXR-Loader] : ReadLayerDataFilesInRegistry - failed to read registry location \ApiLayers\Implicit in either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER
Info [GENERAL |  | OpenXR-Loader] : RuntimeManifestFile::FindManifestFiles - using registry-specified runtime file C:\Program Files\Oculus\Support\oculus-runtime\oculus_openxr_64.json
Info [GENERAL |  | OpenXR-Loader] : RuntimeManifestFile::FindManifestFiles - using global runtime file C:\Program Files\Oculus\Support\oculus-runtime\oculus_openxr_64.json
Info [GENERAL |  | OpenXR-Loader] : RuntimeManifestFile::CreateIfValid - attempting to load C:\Program Files\Oculus\Support\oculus-runtime\oculus_openxr_64.json
Info [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : RuntimeInterface::LoadRuntime succeeded loading runtime defined in manifest file C:\Program Files\Oculus\Support\oculus-runtime\oculus_openxr_64.json using interface version 1 and OpenXR API version 1.0
Verbose [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : Completed loader trampoline
Verbose [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : Entering loader trampoline
Warning [GENERAL |  | OpenXR-Loader] : ReadLayerDataFilesInRegistry - failed to read registry location \ApiLayers\Implicit in either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER
Verbose [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : Completed loader trampoline
Verbose [GENERAL | xrEnumerateApiLayerProperties | OpenXR-Loader] : Entering loader trampoline
Warning [GENERAL |  | OpenXR-Loader] : ReadLayerDataFilesInRegistry - failed to read registry location \ApiLayers\Implicit in either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER
Verbose [GENERAL | xrEnumerateApiLayerProperties | OpenXR-Loader] : Entering loader trampoline
Warning [GENERAL |  | OpenXR-Loader] : ReadLayerDataFilesInRegistry - failed to read registry location \ApiLayers\Implicit in either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER
[10:20:41.764][Info   ] Available Layers: (2)
Verbose [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : Entering loader trampoline
Warning [GENERAL |  | OpenXR-Loader] : ReadLayerDataFilesInRegistry - failed to read registry location \ApiLayers\Implicit in either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER
Verbose [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : Completed loader trampoline
Verbose [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : Entering loader trampoline
Warning [GENERAL |  | OpenXR-Loader] : ReadLayerDataFilesInRegistry - failed to read registry location \ApiLayers\Implicit in either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER
Verbose [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : Completed loader trampoline
Verbose [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : Entering loader trampoline
Warning [GENERAL |  | OpenXR-Loader] : ReadLayerDataFilesInRegistry - failed to read registry location \ApiLayers\Implicit in either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER
Verbose [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : Completed loader trampoline
Verbose [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : Entering loader trampoline
Warning [GENERAL |  | OpenXR-Loader] : ReadLayerDataFilesInRegistry - failed to read registry location \ApiLayers\Implicit in either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER
Verbose [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : Completed loader trampoline
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Entering loader trampoline
Warning [GENERAL |  | OpenXR-Loader] : ReadLayerDataFilesInRegistry - failed to read registry location \ApiLayers\Implicit in either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER

@robbiesri
Copy link
Contributor Author

Added the changelog fragment!

@rpavlik
Copy link
Contributor

rpavlik commented May 20, 2021

Thanks very much!

@rpavlik rpavlik merged commit abccd2e into KhronosGroup:master May 20, 2021
rpavlik added a commit that referenced this pull request Jun 8, 2021
This release features an important fix to the loader for an
invalid-iterator bug introduced in 1.0.16. All developers shipping the
loader are strongly encouraged to upgrade. It also includes a variety of
new vendor extensions.

-   Registry
    -   Add XR_MSFT_scene_understanding vendor extension. (internal MR
        2032)
    -   Add XR_MSFT_scene_understanding_serialization vendor extension.
        (internal MR 2032)
    -   Add XR_MSFT_composition_layer_reprojection vendor extension.
        (internal MR 2033)
    -   Add XR_OCULUS_audio_device_guid vendor extension. (internal MR
        2053)
    -   Add version 3 of XR_FB_swapchain_update_state vendor extension,
        which splits platform and graphics API specific structs into
        separate extensions. (internal MR 2059)
    -   Apply formatting to registry XML by selectively committing
        changes made by https://github.com/rpavlik/PrettyRegistryXml.
        (internal MR 2070, OpenXR-SDK-Source/#256)
    -   Enforce that all xrCreate functions must be able to return
        XR_ERROR_LIMIT_REACHED and XR_ERROR_OUT_OF_MEMORY, and adjust
        lists of error codes accordingly. (internal MR 2064)
    -   Fix a usage of > without escaping as an XML entity. (internal MR
        2064)
    -   Fix all cases of a success code (most often
        XR_SESSION_LOSS_PENDING) appearing in the errorcodes attribute
        of a command. (internal MR 2064, internal issue 1566)
    -   Improve comments for several enum values. (internal MR 1982)
    -   Perform some script clean-up and refactoring, including
        selective type annotation and moving the Conventions abstract
        base class to spec_tools. (internal MR 2064)
    -   Sort return codes, with some general, popular codes made to be
        early. Script sort_codes.py can be used to maintain this, though
        it mangles other XML formatting, so use it with care.
        https://github.com/rpavlik/PrettyRegistryXml can format, and
        eventually sort return codes (currently sort order does not
        match). (internal MR 2064, OpenXR-SDK-Source/#256)
-   SDK
    -   Loader: Fix iteration over explicit layer manifests.
        (OpenXR-SDK-Source/#256)
    -   validation layer: Don’t try to apply strlen to wchar_t-based
        output buffers. (internal MR 2053)
rhabacker pushed a commit to rhabacker/OpenXR-SDK-Source that referenced this pull request Nov 16, 2022
This release features an important fix to the loader for an
invalid-iterator bug introduced in 1.0.16. All developers shipping the
loader are strongly encouraged to upgrade. It also includes a variety of
new vendor extensions.

-   Registry
    -   Add XR_MSFT_scene_understanding vendor extension. (internal MR
        2032)
    -   Add XR_MSFT_scene_understanding_serialization vendor extension.
        (internal MR 2032)
    -   Add XR_MSFT_composition_layer_reprojection vendor extension.
        (internal MR 2033)
    -   Add XR_OCULUS_audio_device_guid vendor extension. (internal MR
        2053)
    -   Add version 3 of XR_FB_swapchain_update_state vendor extension,
        which splits platform and graphics API specific structs into
        separate extensions. (internal MR 2059)
    -   Apply formatting to registry XML by selectively committing
        changes made by https://github.com/rpavlik/PrettyRegistryXml.
        (internal MR 2070, OpenXR-SDK-Source/KhronosGroup#256)
    -   Enforce that all xrCreate functions must be able to return
        XR_ERROR_LIMIT_REACHED and XR_ERROR_OUT_OF_MEMORY, and adjust
        lists of error codes accordingly. (internal MR 2064)
    -   Fix a usage of > without escaping as an XML entity. (internal MR
        2064)
    -   Fix all cases of a success code (most often
        XR_SESSION_LOSS_PENDING) appearing in the errorcodes attribute
        of a command. (internal MR 2064, internal issue 1566)
    -   Improve comments for several enum values. (internal MR 1982)
    -   Perform some script clean-up and refactoring, including
        selective type annotation and moving the Conventions abstract
        base class to spec_tools. (internal MR 2064)
    -   Sort return codes, with some general, popular codes made to be
        early. Script sort_codes.py can be used to maintain this, though
        it mangles other XML formatting, so use it with care.
        https://github.com/rpavlik/PrettyRegistryXml can format, and
        eventually sort return codes (currently sort order does not
        match). (internal MR 2064, OpenXR-SDK-Source/KhronosGroup#256)
-   SDK
    -   Loader: Fix iteration over explicit layer manifests.
        (OpenXR-SDK-Source/KhronosGroup#256)
    -   validation layer: Don’t try to apply strlen to wchar_t-based
        output buffers. (internal MR 2053)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants