Skip to content
  • Arkadiusz Hiler's avatar
    runner_tests: Operate within defined behavior · 9c6bda2c
    Arkadiusz Hiler authored
    
    
    Quoting lib/igt_core.c:
     * - Code blocks with magic control flow are implemented with setjmp() and
     *   longjmp(). This applies to #igt_fixture and #igt_subtest blocks and all the
     *   three variants to finish test: igt_success(), igt_skip() and igt_fail().
     *   Mostly this is of no concern, except when such a control block changes
     *   stack variables defined in the same function as the control block resides.
     *   Any store/load behaviour after a longjmp() is ill-defined for these
     *   variables. Avoid such code.
     *
     *   Quoting the man page for longjmp():
     *
     *   "The values of automatic variables are unspecified after a call to
     *   longjmp() if they meet all the following criteria:"
     *    - "they are local to the function that made the corresponding setjmp() call;
     *    - "their values are changed between the calls to setjmp() and longjmp(); and
     *    - "they are not declared as volatile."
    
    We have quite a few igt_subtest_group that define local variables to
    share the state between subtest and fixture (e.g. set open() in subtest,
    close() in the following fixture), causing the contents to be undefined.
    
    We can allocate some of them using malloc and make the others volatile
    to be back on the defined grounds.
    
    Cc: Petri Latvala <petri.latvala@intel.com>
    Signed-off-by: default avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
    Reviewed-by: default avatarPetri Latvala <petri.latvala@intel.com>
    9c6bda2c