Track.cpp Assertions

5 Messages Forum Options Options
Permalink
Martyn Shaw-2
Track.cpp Assertions
Reply Threaded More
Print post
Permalink
Hi Richard

The new bit in Track *TrackListIterator::RemoveCurrent() has been
causing me grief and I'm really not sure it's correct.  It reads

    #ifdef DEBUG_TLI // if we are debugging this bit
    wxASSERT_MSG(((*l).Contains((*cur).t)), wxT("cur invalid after
deletion of track."));   // check that cur is in the list
    #endif

but I get an error (not assertion) if I delete the last track, as cur
is not valid, and so I guess (*cur).t is not valid.

Is it OK to put
    if(cur)
       wxASSERT_MSG(((*l).Contains((*cur).t)), wxT("cur invalid after
deletion of track."));   // check that cur
for this one?  I have been using it like that and haven't had any
errors or assertions.

Thanks
Martyn

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
audacity-devel mailing list
audacity-devel@...
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Michael Chinen
Re: Track.cpp Assertions
Reply Threaded More
Print post
Permalink
2008/7/8 Martyn Shaw <martynshaw99@...>:

> Hi Richard
>
> The new bit in Track *TrackListIterator::RemoveCurrent() has been
> causing me grief and I'm really not sure it's correct.  It reads
>
>    #ifdef DEBUG_TLI // if we are debugging this bit
>    wxASSERT_MSG(((*l).Contains((*cur).t)), wxT("cur invalid after
> deletion of track."));   // check that cur is in the list
>    #endif
>
> but I get an error (not assertion) if I delete the last track, as cur
> is not valid, and so I guess (*cur).t is not valid.
>
> Is it OK to put
>    if(cur)
>       wxASSERT_MSG(((*l).Contains((*cur).t)), wxT("cur invalid after
> deletion of track."));   // check that cur
> for this one?  I have been using it like that and haven't had any
> errors or assertions.

That bit crashes my audacity for me when I close a wavetrack within a project.

Michael

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
audacity-devel mailing list
audacity-devel@...
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Jan Kolar
Re: Track.cpp Assertions
Reply Threaded More
Print post
Permalink
There are about three similar lines in the file.

I think at least this one  should read   " !cur || "

wxASSERT_MSG(( !cur || (*l).Contains((*cur).t)), wxT("cur invalid after deletion of track."));   // check that cur is in the list


otherwise it crashes (e.g. on cygwin - this might be connected to wx
unable to catch exceptions as configure or make noted on this platform).

Jan


(There is another issue with asserts: wxASSERT's reentrancy fix contains
a bug that actually unfixes it and leads to memory corruption in wx.)


Martyn Shaw napsal(a):

> Hi Richard
>
> The new bit in Track *TrackListIterator::RemoveCurrent() has been
> causing me grief and I'm really not sure it's correct.  It reads
>
>     #ifdef DEBUG_TLI // if we are debugging this bit
>     wxASSERT_MSG(((*l).Contains((*cur).t)), wxT("cur invalid after
> deletion of track."));   // check that cur is in the list
>     #endif
>
> but I get an error (not assertion) if I delete the last track, as cur
> is not valid, and so I guess (*cur).t is not valid.
>
> Is it OK to put
>     if(cur)
>        wxASSERT_MSG(((*l).Contains((*cur).t)), wxT("cur invalid after
> deletion of track."));   // check that cur
> for this one?  I have been using it like that and haven't had any
> errors or assertions.
>
> Thanks
> Martyn
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
> _______________________________________________
> audacity-devel mailing list
> audacity-devel@...
> https://lists.sourceforge.net/lists/listinfo/audacity-devel
>  


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
audacity-devel mailing list
audacity-devel@...
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Gale Andrews
Re: Track.cpp Assertions
Reply Threaded More
Print post
Permalink

| From "Michael Chinen" <mchinen@...>
| Tue, 8 Jul 2008 19:13:15 -0400
| Subject: [Audacity-devel] Track.cpp Assertions

> 2008/7/8 Martyn Shaw <martynshaw99@...>:
> > Hi Richard
> >
> > The new bit in Track *TrackListIterator::RemoveCurrent() has been
> > causing me grief and I'm really not sure it's correct.  It reads
> >
> >    #ifdef DEBUG_TLI // if we are debugging this bit
> >    wxASSERT_MSG(((*l).Contains((*cur).t)), wxT("cur invalid after
> > deletion of track."));   // check that cur is in the list
> >    #endif
> >
> > but I get an error (not assertion) if I delete the last track, as cur
> > is not valid, and so I guess (*cur).t is not valid.
> >
> > Is it OK to put
> >    if(cur)
> >       wxASSERT_MSG(((*l).Contains((*cur).t)), wxT("cur invalid after
> > deletion of track."));   // check that cur
> > for this one?  I have been using it like that and haven't had any
> > errors or assertions.
>
> That bit crashes my audacity for me when I close a wavetrack within a project.

We also had a report on Vista (presumbly with 1.3.5) of crashes when closing  
a track, but I get no problem with crashes if I do that on Win XP in CVS
by clicking [X]. I'm not running debug build though so I don't see any
error reports.



Gale


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
audacity-devel mailing list
audacity-devel@...
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Richard Ash (audacity-help)
Re: Track.cpp Assertions
Reply Threaded More
Print post
Permalink
On Tue, 2008-07-08 at 23:52 +0100, Martyn Shaw wrote:

> The new bit in Track *TrackListIterator::RemoveCurrent() has been
> causing me grief and I'm really not sure it's correct.  It reads
>
>     #ifdef DEBUG_TLI // if we are debugging this bit
>     wxASSERT_MSG(((*l).Contains((*cur).t)), wxT("cur invalid after
> deletion of track."));   // check that cur is in the list
>     #endif
>
> but I get an error (not assertion) if I delete the last track, as cur
> is not valid, and so I guess (*cur).t is not valid.
Ah, hadn't found that one. The reason I put all those in was because I
was crashing audacity because cur pointed outside the application
address space. My hope is that we will work out how it ends up pointing
there and fix the crashes.

> Is it OK to put
>     if(cur)
>        wxASSERT_MSG(((*l).Contains((*cur).t)), wxT("cur invalid after
> deletion of track."));   // check that cur
> for this one?  I have been using it like that and haven't had any
> errors or assertions.

Better to avoid the if (cur) when asserts are off, hence

wxASSERT_MSG((!cur || (*l).Contains((*cur).t)), wxT("cur invalid after
deletion of track."));

As I used somewhere else for the same reason.

Richard


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
audacity-devel mailing list
audacity-devel@...
https://lists.sourceforge.net/lists/listinfo/audacity-devel