Menu

#10 ResetStreamPos causes SegFault if called after Read.

v1.0 (example)
closed-fixed
None
5
2015-08-06
2015-05-19
No

CPGFImage.ResetStreamPos() causes a Segmentation Fault error if called after CPGFImage.Read(...)
If I try to Read more than one ROI from an open PGFImage, the second Read fails, because the first Read left the stream in the wrong position. It looks like the ResetSreamPos function was intended to fix this, but currently it crashes too. It seems, after the first Read, CDecoder.m_stream is pointing at an invalid memory location. My current workaround is to close and re-open the PGF file after each Read call.

Discussion

  • Christoph Stamm

    Christoph Stamm - 2015-05-20

    Hello Rene

    Thank you for message. There is a simple solution for your problem: just
    delete in PGFimage.cpp the last line in the second Read procedure (probably
    line 561). In this line the decoder is automatically closed after reading.
    While this automatic closing might be useful in non ROI reads, in ROI read
    it is disruptive. After deleting this line you can read several ROIs after
    each other:

    pgf.Open(...)
    pgf.Read(rect1);
    pgf.ResetStreamPos();
    pgf.Read(rect2);
    pgf.Close();

    void CPGFImage::Read(PGFRect& rect, int level /= 0/, CallbackPtr cb /=
    nullptr
    /, void data /=nullptr*/

    ) {

    ...

    // automatically closing: should be deleted

    //if (m_currentLevel == 0) Close();
    }

    Chris

    Quoting Rene Lindsay rjklindsay@users.sf.net:


    [BUGS:#10][1] RESETSTREAMPOS CAUSES SEGFAULT IF CALLED AFTER READ.

    STATUS: unread
    GROUP: v1.0 (example)
    CREATED: Tue May 19, 2015 12:46 PM UTC by Rene Lindsay
    LAST UPDATED: Tue May 19, 2015 12:46 PM UTC
    OWNER: nobody

    CPGFImage.ResetStreamPos() causes a Segmentation Fault error if
    called after CPGFImage.Read(...)
    If I try to Read more than one ROI from an open PGFImage, the second
    Read fails, because the first Read left the stream in the wrong
    position. It looks like the ResetSreamPos function was intended to fix
    this, but currently it crashes too. It seems, after the first Read,
    CDecoder.m_stream is pointing at an invalid memory location. My current
    workaround is to close and re-open the PGF file after each Read call.


    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/libpgf/bugs/10/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

    [1] http://sourceforge.net/p/libpgf/bugs/10

     
  • Christoph Stamm

    Christoph Stamm - 2015-05-20
    • status: unread --> closed-fixed
     
  • Christoph Stamm

    Christoph Stamm - 2015-08-06
    • assigned_to: Christoph Stamm
     

Log in to post a comment.

MongoDB Logo MongoDB