Re: [Audacity-devel] bug 1808 sbsms
A free multi-track audio editor and recorder
Brought to you by:
aosiniao
|
From: Paul L. <pau...@gm...> - 2018-01-06 20:13:18
|
On Sat, Jan 6, 2018 at 2:20 PM, Henric Jungheim <sof...@he...> wrote: > > Wouldn't that mean writing N bytes of zeros every time N > bytes are read from the ring buffer? > You mean at most N. "grow" might better have been called "reserve." It means, guarantee at least so many places at write_pos. The assumption in the memmove is that there are. Yes, some zeroes, but I have enough other glimmerings of understanding now to think it's harmless. Pay attention to the difference between big N (a member of the class) and little n (what's really getting consumed). The object has a "length" field. It keeps 2 * length elements allocated. It has a read_pos always not more than write_pos. When elements are consumed past the mid-point, this routine shifts data left and adjusts the offsets. The complication is that there may also be partially ready data at and after write_pos to be preserved too. See void SampleBuf :: write(grain *g, int h) in buffer.cpp. It may advance write_pos a nonzero amount h, less than the growth parameter N. I think this computes batches of transformed samples with tails, of total length N >= h, and does overlap-add. I confirmed that this routine is hit before the crash. Note though that the condition guaranteed by grow(N) at the top of that is NO LONGER guaranteed after write_pos advances by h, and I think that's why advance() can then go wrong, and needs grow(N) to repair the condition again. So I think N is meant to be the *upper* *bound* of the size of the partly computed stuff still in the buffer. To fix advance, either maintain an exact bound (hard) or do what I did (easy but a little wasteful). Or maybe instead, grow(N + h) in SampleBuf::write would also work. PRL > > BTW, the effect of running the test here was an exception on > line 1348 of ProgressDialog.cpp: > Exception thrown: read access violation. > this->mGauge->**** was 0xFDFDFDFD. occurred > > Note that the fdfdfdfd pattern is used by VC++'s debug > malloc() to mark the guards before and after heap > allocations. > https://en.wikipedia.org/wiki/Magic_number_(programming) > > That could, of course, be the result of a wild memmove() > clobbering things elsewhere after reading outside an > allocated buffer. > > On Sat, Jan 06, 2018 at 02:00:20PM -0500, Paul Licameli wrote: > > EUREKA! > > > > I think I figured out a one-line fix in the library, without needing to > > understand all of it. Just examining the ring buffer classes to find the > > error in memory management. > > > > The fix is this the grow(N) line: > > > > template<class T> > > void ArrayRingBuffer<T> :: advance(long n) { > > * grow(N);* > > memset(buf+readPos,0,n*sizeof(T)); > > readPos += n; > > if(readPos >= length) { > > long endPos; > > endPos = writePos+N; > > memmove(buf,buf+readPos,(endPos-readPos)*sizeof(T)); > > memset(buf+readPos,0,((length<<1)-readPos)*sizeof(T)); > > writePos -= readPos; > > readPos = 0; > > } > > } > > > > I can now Undo and Repeat Last Effect many times in the originally > reported > > use case. > > > > Please try the others again on your system. > > > > PRL > > > > > > > > On Sat, Jan 6, 2018 at 1:50 PM, Paul Licameli <pau...@gm...> > > wrote: > > > > > > > > > > > On Sat, Jan 6, 2018 at 1:35 PM, Steve the Fiddle < > ste...@gm... > > > > wrote: > > > > > >> These steps give a repeatable freeze: > > >> > > >> 1) Launch Audacity > > >> 2) Set Project rate to 11025 > > >> 3) Generate 0.3 s 440 Hz tone. > > >> 4) Apply "Change Pitch" effect to the track: > > >> % change: 5 > > >> Use High Quality: enabled > > >> > > > > > > I find that it is only sometimes repeatable. Sometimes it works, then > I > > > Undo, then Repeat last effect. After one or two passes generally I > get the > > > crash. > > > > > > So don't judge good and bad use cases hastily from one trial. > > > > > > Proximate cause of the crash (not freeze) for me in macOS is some > error in > > > memory management in the class ArrayRingBuffer<T> in the (almost > endirely > > > un-commented!) SBSMS library. A buffer is accessed past its end. > > > > > > But bad memory accesses might have various effects with the operating > > > system. > > > > > > > > >> > > >> > > >> These steps do not freeze: > > >> > > >> 1) Launch Audacity > > >> 2) Set Project rate to 11025 > > >> 3) Generate 0.3 s 440 Hz tone. > > >> 4) Add a split line near the middle. > > >> 5) Apply "Change Pitch" effect to the track: > > >> % change: 5 > > >> Use High Quality: enabled > > >> > > > > > > > > > Are you sure you can undo and repeat a few times with no crash? > > > > > > > > >> > > >> > > >> and these steps do not freeze: > > >> > > >> 1) Launch Audacity > > >> 2) Set Project rate to 11025 > > >> 3) Generate 0.3 s 440 Hz tone. > > >> 4) Add some arbitrary audio later in the track. > > >> 5) Apply "Change Pitch" effect to the 0.3s clip at the start: > > >> % change: 5 > > >> Use High Quality: enabled > > >> > > > > > > Ditto ? > > > > > > PRL > > > > > > > > >> > > >> > > >> The only case so far where I can reliably reproduce a crash or freeze, > > >> is to have close to 0.3 seconds of 11025 Hz sample rate audio in a > > >> track (not necessarily at the start of the track). > > >> > > >> ------------------------------------------------------------ > > >> ------------------ > > >> Check out the vibrant tech community on one of the world's most > > >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > >> _______________________________________________ > > >> audacity-devel mailing list > > >> aud...@li... > > >> https://lists.sourceforge.net/lists/listinfo/audacity-devel > > >> > > > > > > > > > ------------------------------------------------------------ > ------------------ > > Check out the vibrant tech community on one of the world's most > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > _______________________________________________ > > audacity-devel mailing list > > aud...@li... > > https://lists.sourceforge.net/lists/listinfo/audacity-devel > > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > audacity-devel mailing list > aud...@li... > https://lists.sourceforge.net/lists/listinfo/audacity-devel > |