Bug 127309 - -fsanitize=float-cast-overflow of nRepeats from -1.0 to sal_uInt32 in SimpleContinuousActivityBase::perform
Summary: -fsanitize=float-cast-overflow of nRepeats from -1.0 to sal_uInt32 in SimpleC...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Slide-Show
  Show dependency treegraph
 
Reported: 2019-09-03 12:10 UTC by Stephan Bergmann
Modified: 2023-04-23 18:45 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Bergmann 2019-09-03 12:10:06 UTC
At least with a recent Linux ASan+UBSan master build, with Contoso-Presentation.pptx as obtained from bug 127258 comment 0, "Slide Show - Start from First Slide" and then pressing space bar four times to go past the first effect on the third slide, sometimes causes

[...]
> debug:16922:16922: SBSBSB.1 -0.757713 0.5 -1.51543
> debug:16922:16922: SBSBSB.2 1 1
> debug:16922:16922: SBSBSB.8 -0.515426 -1
> debug:16922:16922: SBSBSB.10 -1
> slideshow/source/engine/activities/simplecontinuousactivitybase.cxx:241:53: runtime error: -1 is outside the range of representable values of type 'unsigned int'
>  #0 in slideshow::internal::SimpleContinuousActivityBase::perform() at slideshow/source/engine/activities/simplecontinuousactivitybase.cxx:241:53 (instdir/program/../program/libslideshowlo.so +0x134b4b2)
>  #1 in slideshow::internal::ActivitiesQueue::process() at slideshow/source/engine/activitiesqueue.cxx:103:44 (instdir/program/../program/libslideshowlo.so +0x133aadc)
>  #2 in (anonymous namespace)::SlideShowImpl::update(double&) at slideshow/source/engine/slideshowimpl.cxx:1977:31 (instdir/program/../program/libslideshowlo.so +0x18550e5)
>  #3 in sd::SlideshowImpl::updateSlideShow() at sd/source/ui/slideshow/slideshowimpl.cxx:1673:21 (instdir/program/../program/libsdlo.so +0x4a14de8)
>  #4 in Scheduler::ProcessTaskScheduling() at vcl/source/app/scheduler.cxx:479:20 (instdir/program/libvcllo.so +0x7b5ab95)
>  #5 in sal_gtk_timeout_dispatch(_GSource*, int (*)(void*), void*) at vcl/unx/gtk3/gtk3gtkdata.cxx:761:45 (instdir/program/libvclplug_gtk3lo.so +0xd60d41)
>  #6 in g_main_dispatch at ../glib/gmain.c:3189:28 (/lib64/libglib-2.0.so.0 +0x4fedc)
>  #7 in g_main_context_dispatch at ../glib/gmain.c:3854:7 (/lib64/libglib-2.0.so.0 +0x4fedc)
>  #8 in g_main_context_iterate at ../glib/gmain.c:3927:5 (/lib64/libglib-2.0.so.0 +0x5026f)
>  #9 in g_main_context_iteration at ../glib/gmain.c:3988:12 (/lib64/libglib-2.0.so.0 +0x50312)
>  #10 in GtkSalData::Yield(bool, bool) at vcl/unx/gtk3/gtk3gtkdata.cxx:528:31 (instdir/program/libvclplug_gtk3lo.so +0xd5bb41)
>  #11 in ImplYield(bool, bool) at vcl/source/app/svapp.cxx:447:48 (instdir/program/libvcllo.so +0x7be6b9a)
>  #12 in Application::Yield() at vcl/source/app/svapp.cxx:511:5 (instdir/program/libvcllo.so +0x7be60e9)
>  #13 in Application::Execute() at vcl/source/app/svapp.cxx:428:9 (instdir/program/libvcllo.so +0x7be60e9)
>  #14 in desktop::Desktop::Main() at desktop/source/app/app.cxx:1620:17 (instdir/program/libsofficeapp.so +0x732047)
>  #15 in ImplSVMain() at vcl/source/app/svmain.cxx:191:35 (instdir/program/libvcllo.so +0x7c40097)
>  #16 in soffice_main at desktop/source/app/sofficemain.cxx:177:12 (instdir/program/libsofficeapp.so +0x83c920)
>  #17 in sal_main at desktop/source/app/main.c:48:15 (instdir/program/soffice.bin +0x32502a)
>  #18 in main at desktop/source/app/main.c:47:1 (instdir/program/soffice.bin +0x32502a)
>  #19 in __libc_start_main at /usr/src/debug/glibc-2.29-24-g2ec0b166bf/csu/../csu/libc-start.c:308:16 (/lib64/libc.so.6 +0x23f32)
>  #20 in _start at <null> (instdir/program/soffice.bin +0x24e02d)
> 
> SUMMARY: UndefinedBehaviorSanitizer: float-cast-overflow slideshow/source/engine/activities/simplecontinuousactivitybase.cxx:241:53 in 

(with "SBSBSB..." SAL_DEBUG output produced via the patch given below).

It looks like a negative nT leading to a negative nRepeats is not actually expected here?  (Where the negative maTimer.getElapsedTime() is presumably caused by calls to

>                 mpTimer->adjustTimer( -fLag );

in ActivitiesQueue::process, slideshow/source/engine/activitiesqueue.cxx.)

The patch producing the "SBSBSB..." SAL_DEBUG output is:

> diff --git a/slideshow/source/engine/activities/simplecontinuousactivitybase.cxx b/slideshow/source/engine/activities/simplecontinuousactivitybase.cxx
> index 5566b5883f78..1f91b341cb97 100644
> --- a/slideshow/source/engine/activities/simplecontinuousactivitybase.cxx
> +++ b/slideshow/source/engine/activities/simplecontinuousactivitybase.cxx
> @@ -118,6 +118,7 @@ namespace slideshow
>  
>              const double nCurrElapsedTime( maTimer.getElapsedTime() );
>              double nT( nCurrElapsedTime / mnMinSimpleDuration );
> +            SAL_DEBUG("SBSBSB.1 "<<nCurrElapsedTime<<" "<<mnMinSimpleDuration<<" "<<nT);
>  
>  
>              // one of the stop criteria reached?
> @@ -138,6 +139,7 @@ namespace slideshow
>                  const double nEffectiveRepeat( isAutoReverse() ?
>                                                 2.0*nRepeatCount :
>                                                 nRepeatCount );
> +                SAL_DEBUG("SBSBSB.2 "<<nRepeatCount<<" "<<nEffectiveRepeat);
>  
>                  // time (or frame count) elapsed?
>                  if( nEffectiveRepeat <= nT )
> @@ -149,6 +151,7 @@ namespace slideshow
>  
>                      // clamp animation to max permissible value
>                      nT = nEffectiveRepeat;
> +                    SAL_DEBUG("SBSBSB.3 "<<nT);
>                  }
>              }
>  
> @@ -165,6 +168,7 @@ namespace slideshow
>                  // divert active duration into repeat and
>                  // fractional part.
>                  const double nFractionalActiveDuration( modf(nT, &nRepeats) );
> +                SAL_DEBUG("SBSBSB.4 "<<nFractionalActiveDuration<<" "<<nRepeats);
>  
>                  // for auto-reverse, map ranges [1,2), [3,4), ...
>                  // to ranges [0,1), [1,2), etc.
> @@ -172,17 +176,20 @@ namespace slideshow
>                  {
>                      // we're in an odd range, reverse sweep
>                      nRelativeSimpleTime = 1.0 - nFractionalActiveDuration;
> +                    SAL_DEBUG("SBSBSB.5 "<<nRelativeSimpleTime);
>                  }
>                  else
>                  {
>                      // we're in an even range, pass on as is
>                      nRelativeSimpleTime = nFractionalActiveDuration;
> +                    SAL_DEBUG("SBSBSB.6 "<<nRelativeSimpleTime);
>                  }
>  
>                  // effective repeat count for autoreverse is half of
>                  // the input time's value (each run of an autoreverse
>                  // cycle is half of a repeat)
>                  nRepeats /= 2;
> +                SAL_DEBUG("SBSBSB.7 "<<nRepeats);
>              }
>              else
>              {
> @@ -194,6 +201,7 @@ namespace slideshow
>                  // nT gives the relative simple time, and the
>                  // integer part the number of full repeats:
>                  nRelativeSimpleTime = modf(nT, &nRepeats);
> +                SAL_DEBUG("SBSBSB.8 "<<nRelativeSimpleTime<<" "<<nRepeats);
>  
>                  // clamp repeats to max permissible value (maRepeats.getValue() - 1.0)
>                  if( isRepeatCountValid() &&
> @@ -220,12 +228,14 @@ namespace slideshow
>                      // nRelativeSimpleTime=1.0.
>                      nRelativeSimpleTime = 1.0;
>                      nRepeats -= 1.0;
> +                    SAL_DEBUG("SBSBSB.9 "<<nRelativeSimpleTime<<" "<<nRepeats);
>                  }
>              }
>  
>              // actually perform something
>              // ==========================
>  
> +            SAL_DEBUG("SBSBSB.10 "<<nRepeats);
>              simplePerform( nRelativeSimpleTime,
>                             // nRepeats is already integer-valued
>                             static_cast<sal_uInt32>( nRepeats ) );
Comment 1 Xisco Faulí 2019-09-23 14:27:56 UTC
Moving to NEW
Comment 2 QA Administrators 2021-09-24 04:06:40 UTC
Dear Stephan Bergmann,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://kiwiirc.com/nextclient/irc.freenode.net/#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug