سؤال

My core file claims that a SIGFPE was thrown from

gcc-4.3.4/include/c++/4.3.4/bits/stl_iterator_base_funcs.h

on line 176. This is here:

  template<typename _InputIterator, typename _Distance>
    inline void
    advance(_InputIterator& __i, _Distance __n)
    {
          // concept requirements -- taken care of in __advance
176---->  typename iterator_traits<_InputIterator>::difference_type __d = __n;
          std::__advance(__i, __d, std::__iterator_category(__i));
    }

this is inside another function I have that is indeed calling advance surrounding by code that isn't doing any floating point arithmetic. The code is compiled with optimizations (but has debugging symbols), so things may be a big obfuscated.

Is my core file just telling me complete nonsense or is there a way this could make sense?

هل كانت مفيدة؟

المحلول

In answer to my own question, what happened is that optimizer took code that looked like this:

int which = RANDOM % somecontainer.size();
std::advance(it, which);

and combined them. This is why it appears the signal was raised from inside std::advance. Following Oli's comment, SIGFPE can occur when you take the modulus with respect to 0, even though it isn't a floating point operation. There was a different bug which allowed somecontainer to be empty in a corner case.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top