Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Severe error in filtering procedure - critical memory corruption #15

Closed
vmarkovtsev opened this issue Dec 3, 2013 · 1 comment
Closed

Comments

@vmarkovtsev
Copy link

Cascade.h, near line 181:

  // Process a block of samples in the given form
  template <class StateType, typename Sample>
  void process (int numSamples, Sample* dest, StateType& state) const
  {
    while (--numSamples >= 0)
      *dest++ = state.process (*dest, *this);
  }

There is a very stupid error: the order of calculation of *dest++ and *dest is unspecified (see this question on StackOverflow). It seems that with Visual C++ it does the right thing, but g++ under Linux compiles the other way, resulting in the first sample to be skipped. Moreover, this actually leads to memory corruption in the end. I recommend the following fix:

  // Process a block of samples in the given form
  template <class StateType, typename Sample>
  void process (int numSamples, Sample* dest, StateType& state) const
  {
    while (--numSamples >= 0) {
      *dest = state.process (*dest, *this);
      dest++;
    }
  }
vmarkovtsev added a commit to vmarkovtsev/DSPFilters that referenced this issue Dec 3, 2013
Pointer arithmetic unspecified behaviour in Cascade.h
vmarkovtsev added a commit to vmarkovtsev/DSPFilters that referenced this issue Jan 15, 2015
gerasim13 added a commit to gerasim13/DSPFilters that referenced this issue Feb 8, 2015
# By Vadim Markovtsev
# Via Vadim Markovtsev
* 'master' of https://github.com/vmarkovtsev/DSPFilters:
  Disabled SSE by default (leads to speed degradation)
  Added RASTA filter
  Weakened poles/zeros assertion in LayoutBase
  Made Cascade::applyScale overridable
  Fixed further Biquad memory corruptions (see vinniefalco#15)
  Renamed PoleFilterBase-s, turned PoleFilterBase2 into a template
@galchinsky
Copy link
Collaborator

Fixed in #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants