Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#81 editing midi causes freeze

git_head
closed
nobody
None
2015-02-01
2013-12-19
Tuomas
No

How to reproduce:
- open a project with midi in it
- double click midi clip to edit it
- do some minor edits (i deleted some notes and moved some)
- click save
-> freeze. It indeed is saving midi file during freeze, as my midi file grew in
few seconds to many gigabytes.

using latest svn.

Discussion

  • Tuomas
    Tuomas
    2013-12-19

    It seems that freeze occurs only if saving from midi edit dialog. If saving from project dialog it's fine.

     
  • Tuomas
    Tuomas
    2013-12-19

    aargh.. does not seem to be a reliable workaround :( freezes every now and then. Maybe I must revert to stable version :D

     
  • Tuomas
    Tuomas
    2013-12-19

    oh no, it's the same also in stable version:(

     
  • Tuomas
    Tuomas
    2013-12-19

    even kilo papa freezes, so it seems to be old bug.

     
  • Tuomas
    Tuomas
    2013-12-19

    Some backtrace from gdb. (latest svn revision of qtractor)

    and some manual debugging on the occasion of this bug.

    (gdb) frame 8
    #8  0x000000000050bf11 in qtractorMidiFile::writeTracks     (this=0x7fff2081fc30, 
        ppSeqs=0x2c17f40, iSeqs=2) at qtractorMidiFile.cpp:833
                        writeInt(iTime >     iLastTime ? iTime - iLastTime : 0);
    
    (gdb) print iTime > iLastTime ? iTime - iLastTime : 0    
    $15 = 573611187
    (gdb) print iTime
    $16 = 619910067
    (gdb) print iLastTime
    $17 = 46298880
    
     
    Last edit: Tuomas 2013-12-19
    Attachments
  • Tuomas
    Tuomas
    2013-12-19

    This replacement code seems to work without freezing. Honestly, I don't have an idea how this works :D Copied&pasted similar function from internet into the while(true) loop ;)

    int qtractorMidiFile::writeInt ( int val, unsigned short n )
    {
            int c;
    
            if (n > 0) {
                    // Fixed length (n bytes) integer write.
                    for (int i = (n - 1) * 8; i >= 0; i -= 8) {
                            c = (val & (0xff << i)) >> i;
                            if (::fputc(c & 0xff, m_pFile) < 0)
                                    return -1;
                            ++m_iOffset;
                    }
            } else {
    
              int n = 0;
              unsigned long buffer;
              unsigned long value = val;
              buffer = value & 0x7f;
              while((value >>= 7) > 0)
              {
                    buffer <<= 8;
                    buffer |= 0x80;
                    buffer += (value & 0x7f);
              }
              while(1){
                   fputc((unsigned)(buffer & 0xff), m_pFile );
                   ++n;
                    if(buffer & 0x80)
                            buffer >>= 8;
                    else
                            break;
                    }
                m_iOffset += n;
            }
    
            return n;
    }
    
     
    Last edit: Tuomas 2013-12-19
  • it would be nice if you provide the offending/original midi file attached here, for me to reproduce the issue.

    indeed the code in question is pretty old but that's no argument for its correcteness. it might be a particular compiler (over)optimization issue, or even really bad code bug lurking since ancient days :)

    cheers

     
  • Tuomas
    Tuomas
    2013-12-20

    I can provide midi file. But in the project there were audio as well.. so
    I try to produce you a midi-only project that is easy with respect to reproducing this bug. I will send you midi file (etc.) by email later.

     
  • thanks for the midi file which was crucial to reproduce the issue.

    hopefully fixed on svn trunk [r3667] aka. qtractor v0.5.11.43+

    test && tell
    thanks again.

     

    Related

    Commit: <Commit 5181bb35a02bb134b2580972:3667>


    Last edit: Rui Nuno Capela 2013-12-21
    • status: open --> pending
     
  • Tuomas
    Tuomas
    2013-12-21

    Quick testing results seem fine.

     
    • status: pending --> closed