Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29107 Discussions

Potential Issue in Dialog Module iflogm

Stephen_Sutcliffe
New Contributor II
61 Views

I use the iflogm (formally dflogm) module for the majority of the GUI dialog boxes in my application and experience seemingly random program crashes when some dialog boxes are being displayed when implementing the DlgModal or DlgModalWithParent function. These crashes are not dependent upon IFORT or IFX compilers.

In order to try and track down the possible cause I copied the latest iflogm.f90 source and added it to my solution so debug code can be generated when compiled.

I compiled this using default compiler setting for debug (including array bounds checking) and there are a number of warnings relating to unused variables and it also picks up, what looks like, redundant C directives #if defined and #endif. I ignored these warnings and compiled and linked the application and when run the program crashed when opening one of the dialog boxes with an array bounds violation with index of 0 in the iflogm function DlgWmCommand. The extract below (full file attached) includes my attempted fix in bold type:

recursive function DlgWmCommand ( dlg, id, code, hwndControl ) result (r)
!DEC$ ATTRIBUTES DEFAULT :: DlgWmCommand
type (dialog), intent(inout) :: dlg
integer(INT_PTR), intent(in) :: id
integer, intent(in) :: code
integer(HANDLE), intent(in) :: hwndControl
integer r
integer(INT_PTR) :: i, j
integer tabid
! supress compiler warning
i = hwndControl
i = id2index( dlg, id )
r = 0
! ignore unsupported controls
if (i .eq. 0 .and. id .eq. IDCANCEL .and. hwndControl .eq. 0) then
call DefaultPushbuttonCallback(dlg,IDCANCEL,0)
return
! Update SS 03-05-2025
else if(i.eq.0) then
return
! End of Update
end if

! if id == IDCANCEL, we treat it as if close button was pushed.
! Don't ignore it even if handle is 0. 09-16-2024
if (hwndControl .eq. 0_HANDLE .and. id .ne. IDCANCEL) then
return
endif

! ignore disabled scrollbar controls wrc 10-13-97
if(dlg % list(i) % control .eq. ctrl_scrollbar) then
if(.not. dlg % list(i) % logvalue(1)) then
return
endif
end if

! if the dialog is not running or if the message
! was caused by our own write then don't call the
! callback
if ( id .eq. 0 .or. dlg % mutexflush ) then
return
endif

In the official iflogm the index i is not checked before being referenced in the if statement containing dlg%list(i) and therefore could cause strange behaviour going forward.

Since switch from 2021 this portion of the code was fairly recently updated to fix an issue with the cancel button X.

Using the modified code (above) seems to have fixed the random crashes.

The dlg%list array contains the control IDs and their attributes that are defined in the resource file but the WM_NOTIFY message sometimes generates IDs that are not any of these hence the 0 return from id2index function.

I'd prefer to revert back to the official version of iflogm at some point so could Intel look into this and also fix the other issues that generated warnings. I also note that much of the definitions use the outdated syntax which may be best brought up to date. I've read on other posts that the IFX debugger doesn't always work on variables defined using the older syntax.

Any relevant comments are also welcome as many contributors will have a far better understanding of this type of code than I.

Thanks

Steve

0 Kudos
0 Replies
Reply