Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Turn off OpenGL optimization via Qt Environment Variable
Forum Update on Monday, May 27th 2025

Turn off OpenGL optimization via Qt Environment Variable

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 3.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sandra_Carney
    wrote on 16 May 2018, 16:39 last edited by
    #1

    Qt version: 5.9
    OS: CentOS 7.4
    Nvidia version: 390.48-1
    OpenGL version string: 4.6.0 NVIDIA 390.48

    We running our software on a whitelisted system. Once we whitelist,
    we can't add new binaries to run.

    We have a number of applications that use Qt+OpenGL.

    Some of the OpenGL software is creating mmap'ed binaries in /tmp.
    They are files of the form /tmp/.gl* where the rest of the text
    is randomly generated.

    In the README file( http://us.download.nvidia.com/XFree86/Linux-x86/390.48/README/openglenvvariables.html#disableexecmem ),
    there is a section that reads:

    Disabling executable memory optimizations

    By default, the NVIDIA driver will attempt to use optimizations which rely
    on being able to write to executable memory. This may cause problems in
    certain system configurations (e.g., on SELinux when the "allow_execmem"
    boolean is disabled or "deny_execmem" boolean is enabled, and on
    grsecurity kernels configured with CONFIG_PAX_MPROTECT). When possible,
    the driver will attempt to detect when it is running on an unsupported
    configuration and disable these optimizations automatically. If
    the __GL_WRITE_TEXT_SECTION environment variable is set to 0,
    the driver will unconditionally disable these optimizations.

    We were hoping the messages would disappear when the variable was set.
    The messages look something like:

    May 15 17:46:02 <hostname> * prevented unauthorized execution of '/tmp/.gl96LhR8' by process <process>
    May 15 17:46:02 <hostname> * prevented unauthorized execution of '/tmp/.gl96LhR8' by process <process>
    May 15 17:46:02 <hostname> * prevented unauthorized execution of '<home>/.nv/.glNpZrDX' by process <process>
    May 15 17:46:02 <hostname> * prevented unauthorized execution of '<home>/.nv/.glNpZrDX' by process <process>

    If we set the variable to 0 in the environment, we see dozens and dozens of such messages
    when we launch our application. If we set the variable to 1 or don't set it at
    all, we see 4 such messages in the log when our application program starts up.

    The strace output indirectly associates libqtgraphicaleffectsprivate.so
    with the creation of the mmap'ed memory executable files.

    We executed 'ldd /path/to/Qt-5.9/qml/QtGraphicalEffects/private/libqtgraphicaleffectsprivate.so'
    and /usr/lib64/nvidia/libGL.so.1, /usr/lib64/nvidia/libGLX.so.0, and
    /usr/lib64/nvidia/libGL_dispatch.so.0, show up.

    I looked around in the Qt documentation starting with the graphical
    effects stuff which lead me to a Qt environment variable which tells
    Qt Quick not to use OpenGL:

    QT_QUICK_BACKEND="software" /path/to/our/application

    With this, the messages disappear from the logs. This is not
    an option, however. We need OpenGL.

    Another option to is to add our application program to an
    updaters list. This tells our whitelisting software the
    program is trusted to create other executables and run them.
    With that, the messages disappear from the log.

    However, this violates our cybersecurity requirements.
    We can't add any directory a trusted list and we have
    a very, very limited set of administrative programs
    that are on the updaters list.

    When we set the environment variable, __GL_WRITE_TEXT_SECTION=0,
    and run /bin/glxgears, a standard program that is supplied by the
    glx-utils package, the optimizations are prevented and hence
    the complaints from our whitelisting software. Without the
    environment variable, execution of /bin/glxgears results
    in the messages.

    We were able to reproduce the problem with one of the Qt example
    programs: /path/to/Qt-5.9/examples/quickcontrols2/texteditor/texteditor.

    We ran the above program while monitoring /var/log/messages.
    4 messages similar to the above were generated by the whitelisting software.

    When we set __GL_WRITE_TEXT_SECTION=0 and ran the same program,
    dozens and dozens of these messages were generated. The environment
    variable had the opposite effect from what we saw with the
    /bin/glxgears program.

    Is there a special way to set this variable due to locale
    or UTF considerations? We are using English for locale.

    Is there another way to disable these optimizatons through
    a Qt environment variable other than telling Qt not to use
    OpenGL via the QT_QUICK_BACKEND environment variable?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 16 May 2018, 17:01 last edited by
      #2

      Hi and welcome to devnet,

      Pretty interesting use case !

      Did you check whether there was already something about it in the bug report system ?

      In any case, I'd recommend bringing this to the interest mailing list. You'll find there Qt's developers/maintainers. This forum is more user oriented.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply 16 May 2018, 17:55
      1
      • S SGaist
        16 May 2018, 17:01

        Hi and welcome to devnet,

        Pretty interesting use case !

        Did you check whether there was already something about it in the bug report system ?

        In any case, I'd recommend bringing this to the interest mailing list. You'll find there Qt's developers/maintainers. This forum is more user oriented.

        S Offline
        S Offline
        Sandra_Carney
        wrote on 16 May 2018, 17:55 last edited by
        #3

        @SGaist I did check the bug database and found nothing there about opengl+whitelisting. I also checked for the environment variable and optimizations. There was nothing relevant.

        I will send to the 'interest mailing list'.

        Thankyou for your quick reply.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sandra_Carney
          wrote on 21 May 2018, 15:46 last edited by
          #4

          @SGaist I performed a post to the interest mailing list as you suggested. Should I receive some sort of reply? I also tried to sign up and have not gotten a response. Is membership constrained to developers in the Qt company?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 21 May 2018, 15:55 last edited by
            #5

            No, there’s no such restriction, but you should registre before posting.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            S 1 Reply Last reply 21 May 2018, 18:18
            0
            • S SGaist
              21 May 2018, 15:55

              No, there’s no such restriction, but you should registre before posting.

              S Offline
              S Offline
              Sandra_Carney
              wrote on 21 May 2018, 18:18 last edited by
              #6

              @SGaist I did try registering twice. Have not heard back although the response could have gotten hung up in the SPAM filter. Have been checking that and haven't seen anything in there. I will keep trying.

              S 1 Reply Last reply 21 May 2018, 18:39
              0
              • S Sandra_Carney
                21 May 2018, 18:18

                @SGaist I did try registering twice. Have not heard back although the response could have gotten hung up in the SPAM filter. Have been checking that and haven't seen anything in there. I will keep trying.

                S Offline
                S Offline
                Sandra_Carney
                wrote on 21 May 2018, 18:39 last edited by
                #7

                @Sandra_Carney OK, I am in. I was trying to use my (new) corporate email. We are now part of Abbott. The old email worked. I will now goto the next step. Thanx.

                1 Reply Last reply
                0

                5/7

                21 May 2018, 15:55

                • Login

                • Login or register to search.
                5 out of 7
                • First post
                  5/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved