Page MenuHomeFeedback Tracker

RenderTargetWidget.SetRefresh() - divide by zero crash
Assigned, NormalPublic

Description

Setting a Refresh value of 0 on a RenderTargetWidget will cause the workspace to crash with a div0 error

Default Layout widget values for RenderTargetWidget are:

Camera: 0
Refresh: 0
Offset: -1

This indicates that Refresh can support a value of 0, even if it functions as if having a value of 1

The tooltip for the Refresh Attribute says:

Limit refresh to n-th frame (min=0, max=255)

Code hint for RenderTargetWidget.SetRefresh() says:

//!when period > 1 then every n-th frame will be rendered. Offset is initial counter.
proto external void SetRefresh(int period, int offset);

This would indicate (to me) that any period below 2 will skip no frames, or at least safely clamp period values to >= 1

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce

Add the following code to a menu:

override void OnMenuInit()
{
    Print("menu init");

    // Create an RT widget
    RenderTargetWidget widget = RenderTargetWidget.Cast(GetGame().GetWorkspace().CreateWidget(WidgetType.RenderTargetWidgetTypeID, WidgetFlags.VISIBLE, new Color(), 100));
    Print("widget created");

    // Set refresh to 1, this succeeds
    widget.SetRefresh(1, -1);
    Print("RT refresh set to 1");

    // Set refresh to 0, this crashes the workspace
    widget.SetRefresh(0, -1); // <-- Crash
    Print("RT refresh set to 0");
}

Script log:

03:53:42.345    SCRIPT       : menu init
03:53:42.346    SCRIPT       : widget created
03:53:42.346    SCRIPT       : RT refresh set to 1

Crash log:

------------------------------------
21.06 2024 03:53:42
Unhandled exception

Program: D:\SteamLibrary\steamapps\common\Arma Reforger Tools\Workbench\ArmaReforgerWorkbenchSteamDiag.exe
Reason: Integer divide by zero


Class:      'TestLayout1Class'
Function: 'OnMenuInit'
Stack trace:
Scripts/Game/UI/Modded/testUIScript1.c:102 Function OnMenuInit
Scripts/Game/UserAction/Modded/testUserActionScript1.c:6 Function PerformAction
Scripts/Game/Interactions/SCR_InteractionHandlerComponent.c:242 Function DoProcessInteraction
Scripts/Game/Interactions/SCR_InteractionHandlerComponent.c:676 Function OnPostFrame

[zlibVersion]: ??? addr:0x7ff63bb26ced
[zlibVersion]: ??? addr:0x7ff63b8afb5f
[zlibVersion]: ??? addr:0x7ff63b6a0038
[zlibVersion]: ??? addr:0x7ff63b69c15d
[zlibVersion]: ??? addr:0x7ff63b69c325
[zlibVersion]: ??? addr:0x7ff63b69cd96
[zlibVersion]: ??? addr:0x7ff63b54f7b8
[zlibVersion]: ??? addr:0x7ff63b54ddf2
[zlibVersion]: ??? addr:0x7ff63b54d04d
[zlibVersion]: ??? addr:0x7ff63b550306
[zlibVersion]: ??? addr:0x7ff63be12cd5
[zlibVersion]: ??? addr:0x7ff63b8add41
[zlibVersion]: ??? addr:0x7ff63b8ae953
[zlibVersion]: ??? addr:0x7ff63b8af71a
[nvtt::CubeSurface::toGamma]: ??? addr:0x7ff63a8f1297
[nvtt::CubeSurface::toGamma]: ??? addr:0x7ff63a8ef0d8
[nvtt::CubeSurface::toGamma]: ??? addr:0x7ff63a8db5d1
[zlibVersion]: ??? addr:0x7ff63b8afb5f
[nvtt::CubeSurface::toGamma]: ??? addr:0x7ff63a8ebe87
[nvtt::CubeSurface::toGamma]: ??? addr:0x7ff63a8ed8af
[zlibVersion]: ??? addr:0x7ff63b48a6a7
[zlibVersion]: ??? addr:0x7ff63b37056a
[zlibVersion]: ??? addr:0x7ff63b36fea7
[zlibVersion]: ??? addr:0x7ff63b6495ec
[zlibVersion]: ??? addr:0x7ff63bb020b9
[nvtt::CubeSurface::toGamma]: ??? addr:0x7ff63a393be2
[zlibVersion]: ??? addr:0x7ff63b251f12
[zlibVersion]: ??? addr:0x7ff63b2d15d5
[nvtt::CubeSurface::toGamma]: ??? addr:0x7ff639d79941
[nvtt::CubeSurface::toGamma]: ??? addr:0x7ff639d16f4b
[nvtt::CubeSurface::toGamma]: ??? addr:0x7ff639d1dcd2
SymGetSymFromAddr:487, addr:0x7ffc4ea1757d
SymGetSymFromAddr:487, addr:0x7ffc4ea1551f
SymGetSymFromAddr:487, addr:0x7ffc4be19b19
SymGetSymFromAddr:487, addr:0x7ffc4be1c0a9
SymGetSymFromAddr:487, addr:0x7ffc58c3306f
SymGetSymFromAddr:487, addr:0x7ffc4be66fb7
SymGetSymFromAddr:487, addr:0x7ffc58c33049
SymGetSymFromAddr:487, addr:0x7ffc4be159c1
SymGetSymFromAddr:487, addr:0x7ffc4be1880b
[nvtt::CubeSurface::toGamma]: ??? addr:0x7ff639c50906
[zlibVersion]: ??? addr:0x7ff63c22a917
[zlibVersion]: ??? addr:0x7ff63c225cce
[BaseThreadInitThunk]: ??? addr:0x7ffc67fe7344
[RtlUserThreadStart]: ??? addr:0x7ffc68ebcc91
[RtlUserThreadStart]: ??? addr:0x7ffc68ebcc91

Event Timeline

Geez changed the task status from New to Assigned.Jun 24 2024, 3:20 PM