Found bug in vc7 mfc code... 
Author Message
 Found bug in vc7 mfc code...

While trying to figure out a "File Format unknown" error in our Application
I found the following:

(release version of visual studio dot net)

File: ...\Microsoft Visual Studio .NET\Vc7\atlmfc\src\mfc\Array_b.cpp:

void CByteArray::Serialize(CArchive& ar)
{
    UINT_PTR nBytesLeft;
    UINT nBytesToWrite;
    UINT nBytesToRead;
    LPBYTE pbData;
    ASSERT_VALID(this);
    CObject::Serialize(ar);
    if (ar.IsStoring())
    {
        ar.WriteCount(m_nSize);
        nBytesLeft = m_nSize*sizeof(BYTE);
        pbData = m_pData;
        while(nBytesLeft > 0)
        {
            nBytesToWrite = UINT(min(nBytesLeft, INT_MAX));
            ar.Write(pbData, nBytesToWrite);
            pbData += nBytesToWrite;
            nBytesLeft -= nBytesToWrite;
        }
    }
    else
    {
        DWORD_PTR nOldSize = ar.ReadCount();
        SetSize(nOldSize);
        nBytesLeft = m_nSize*sizeof(BYTE);
        pbData = m_pData;
        while(nBytesLeft > 0)
        {
            nBytesToRead = UINT(min(nBytesLeft, INT_MAX));
            ar.Read(pbData, nBytesToRead);
            pbData += nBytesToRead;
            nBytesLeft -= nBytesToRead;
            ar.Read(pbData, nBytesToRead);        // <<<<<<<< BUG
        }
   }

Quote:
}

Could somebody advise me what to do about this???


Sun, 11 Jul 2004 01:37:38 GMT  
 Found bug in vc7 mfc code...
Michael,

You are correct, this is a bug that we'll fix in a future service pack.
However, you will only encounter this bug if your array size is greater than
INT_MAX. (Which was also not supported in VC6)

--
Anson Tsao
Visual C++ libraries team

Of course, this posting wouldn't be complete without a nice, juicy
disclaimer from our lawyers: This posting is provided "AS IS" with no
warranties, and confers no rights. You assume all risk for your use. ? 2001
Microsoft Corporation. All rights reserved.


Quote:

> While trying to figure out a "File Format unknown" error in our
Application
> I found the following:

> (release version of visual studio dot net)

> File: ...\Microsoft Visual Studio .NET\Vc7\atlmfc\src\mfc\Array_b.cpp:

> void CByteArray::Serialize(CArchive& ar)
> {
>     UINT_PTR nBytesLeft;
>     UINT nBytesToWrite;
>     UINT nBytesToRead;
>     LPBYTE pbData;
>     ASSERT_VALID(this);
>     CObject::Serialize(ar);
>     if (ar.IsStoring())
>     {
>         ar.WriteCount(m_nSize);
>         nBytesLeft = m_nSize*sizeof(BYTE);
>         pbData = m_pData;
>         while(nBytesLeft > 0)
>         {
>             nBytesToWrite = UINT(min(nBytesLeft, INT_MAX));
>             ar.Write(pbData, nBytesToWrite);
>             pbData += nBytesToWrite;
>             nBytesLeft -= nBytesToWrite;
>         }
>     }
>     else
>     {
>         DWORD_PTR nOldSize = ar.ReadCount();
>         SetSize(nOldSize);
>         nBytesLeft = m_nSize*sizeof(BYTE);
>         pbData = m_pData;
>         while(nBytesLeft > 0)
>         {
>             nBytesToRead = UINT(min(nBytesLeft, INT_MAX));
>             ar.Read(pbData, nBytesToRead);
>             pbData += nBytesToRead;
>             nBytesLeft -= nBytesToRead;
>             ar.Read(pbData, nBytesToRead);        // <<<<<<<< BUG
>         }
>    }
> }

> Could somebody advise me what to do about this???



Sun, 11 Jul 2004 13:20:08 GMT  
 Found bug in vc7 mfc code...
Sorry to say that the bug not only happes as stated below but allways - as
the second read reads nBytesToRead bytes again!!!!

regards,
Michael



Quote:
> Michael,

> You are correct, this is a bug that we'll fix in a future service pack.
> However, you will only encounter this bug if your array size is greater
than
> INT_MAX. (Which was also not supported in VC6)

> --
> Anson Tsao
> Visual C++ libraries team

> Of course, this posting wouldn't be complete without a nice, juicy
> disclaimer from our lawyers: This posting is provided "AS IS" with no
> warranties, and confers no rights. You assume all risk for your use. ?
2001
> Microsoft Corporation. All rights reserved.



> > While trying to figure out a "File Format unknown" error in our
> Application
> > I found the following:

> > (release version of visual studio dot net)

> > File: ...\Microsoft Visual Studio .NET\Vc7\atlmfc\src\mfc\Array_b.cpp:

> > void CByteArray::Serialize(CArchive& ar)
> > {
> >     UINT_PTR nBytesLeft;
> >     UINT nBytesToWrite;
> >     UINT nBytesToRead;
> >     LPBYTE pbData;
> >     ASSERT_VALID(this);
> >     CObject::Serialize(ar);
> >     if (ar.IsStoring())
> >     {
> >         ar.WriteCount(m_nSize);
> >         nBytesLeft = m_nSize*sizeof(BYTE);
> >         pbData = m_pData;
> >         while(nBytesLeft > 0)
> >         {
> >             nBytesToWrite = UINT(min(nBytesLeft, INT_MAX));
> >             ar.Write(pbData, nBytesToWrite);
> >             pbData += nBytesToWrite;
> >             nBytesLeft -= nBytesToWrite;
> >         }
> >     }
> >     else
> >     {
> >         DWORD_PTR nOldSize = ar.ReadCount();
> >         SetSize(nOldSize);
> >         nBytesLeft = m_nSize*sizeof(BYTE);
> >         pbData = m_pData;
> >         while(nBytesLeft > 0)
> >         {
> >             nBytesToRead = UINT(min(nBytesLeft, INT_MAX));
> >             ar.Read(pbData, nBytesToRead);
> >             pbData += nBytesToRead;
> >             nBytesLeft -= nBytesToRead;
> >             ar.Read(pbData, nBytesToRead);        // <<<<<<<< BUG
> >         }
> >    }
> > }

> > Could somebody advise me what to do about this???



Sun, 11 Jul 2004 19:08:23 GMT  
 Found bug in vc7 mfc code...
Michael,

You are absolute right, I apologize! Reading from CByteArray will corrupt
the rest of your CArchive.

Anson


Quote:
> Sorry to say that the bug not only happes as stated below but allways - as
> the second read reads nBytesToRead bytes again!!!!

> regards,
> Michael



> > Michael,

> > You are correct, this is a bug that we'll fix in a future service pack.
> > However, you will only encounter this bug if your array size is greater
> than
> > INT_MAX. (Which was also not supported in VC6)

> > --
> > Anson Tsao
> > Visual C++ libraries team

> > Of course, this posting wouldn't be complete without a nice, juicy
> > disclaimer from our lawyers: This posting is provided "AS IS" with no
> > warranties, and confers no rights. You assume all risk for your use. ?
> 2001
> > Microsoft Corporation. All rights reserved.



> > > While trying to figure out a "File Format unknown" error in our
> > Application
> > > I found the following:

> > > (release version of visual studio dot net)

> > > File: ...\Microsoft Visual Studio .NET\Vc7\atlmfc\src\mfc\Array_b.cpp:

> > > void CByteArray::Serialize(CArchive& ar)
> > > {
> > >     UINT_PTR nBytesLeft;
> > >     UINT nBytesToWrite;
> > >     UINT nBytesToRead;
> > >     LPBYTE pbData;
> > >     ASSERT_VALID(this);
> > >     CObject::Serialize(ar);
> > >     if (ar.IsStoring())
> > >     {
> > >         ar.WriteCount(m_nSize);
> > >         nBytesLeft = m_nSize*sizeof(BYTE);
> > >         pbData = m_pData;
> > >         while(nBytesLeft > 0)
> > >         {
> > >             nBytesToWrite = UINT(min(nBytesLeft, INT_MAX));
> > >             ar.Write(pbData, nBytesToWrite);
> > >             pbData += nBytesToWrite;
> > >             nBytesLeft -= nBytesToWrite;
> > >         }
> > >     }
> > >     else
> > >     {
> > >         DWORD_PTR nOldSize = ar.ReadCount();
> > >         SetSize(nOldSize);
> > >         nBytesLeft = m_nSize*sizeof(BYTE);
> > >         pbData = m_pData;
> > >         while(nBytesLeft > 0)
> > >         {
> > >             nBytesToRead = UINT(min(nBytesLeft, INT_MAX));
> > >             ar.Read(pbData, nBytesToRead);
> > >             pbData += nBytesToRead;
> > >             nBytesLeft -= nBytesToRead;
> > >             ar.Read(pbData, nBytesToRead);        // <<<<<<<< BUG
> > >         }
> > >    }
> > > }

> > > Could somebody advise me what to do about this???



Mon, 12 Jul 2004 01:17:09 GMT  
 Found bug in vc7 mfc code...
So - how can I rebuild the MFC library - I followed the instructions in the
readme located in the mfc source dir (which has worked for me on vs6) but
then I have a lot of unresolved externals. Are there new switches???

Michael



Quote:
> Michael,

> You are absolute right, I apologize! Reading from CByteArray will corrupt
> the rest of your CArchive.

> Anson



> > Sorry to say that the bug not only happes as stated below but allways -
as
> > the second read reads nBytesToRead bytes again!!!!

> > regards,
> > Michael



> > > Michael,

> > > You are correct, this is a bug that we'll fix in a future service
pack.
> > > However, you will only encounter this bug if your array size is
greater
> > than
> > > INT_MAX. (Which was also not supported in VC6)

> > > --
> > > Anson Tsao
> > > Visual C++ libraries team

> > > Of course, this posting wouldn't be complete without a nice, juicy
> > > disclaimer from our lawyers: This posting is provided "AS IS" with no
> > > warranties, and confers no rights. You assume all risk for your use. ?
> > 2001
> > > Microsoft Corporation. All rights reserved.


message

> > > > While trying to figure out a "File Format unknown" error in our
> > > Application
> > > > I found the following:

> > > > (release version of visual studio dot net)

> > > > File: ...\Microsoft Visual Studio

.NET\Vc7\atlmfc\src\mfc\Array_b.cpp:

- Show quoted text -

Quote:

> > > > void CByteArray::Serialize(CArchive& ar)
> > > > {
> > > >     UINT_PTR nBytesLeft;
> > > >     UINT nBytesToWrite;
> > > >     UINT nBytesToRead;
> > > >     LPBYTE pbData;
> > > >     ASSERT_VALID(this);
> > > >     CObject::Serialize(ar);
> > > >     if (ar.IsStoring())
> > > >     {
> > > >         ar.WriteCount(m_nSize);
> > > >         nBytesLeft = m_nSize*sizeof(BYTE);
> > > >         pbData = m_pData;
> > > >         while(nBytesLeft > 0)
> > > >         {
> > > >             nBytesToWrite = UINT(min(nBytesLeft, INT_MAX));
> > > >             ar.Write(pbData, nBytesToWrite);
> > > >             pbData += nBytesToWrite;
> > > >             nBytesLeft -= nBytesToWrite;
> > > >         }
> > > >     }
> > > >     else
> > > >     {
> > > >         DWORD_PTR nOldSize = ar.ReadCount();
> > > >         SetSize(nOldSize);
> > > >         nBytesLeft = m_nSize*sizeof(BYTE);
> > > >         pbData = m_pData;
> > > >         while(nBytesLeft > 0)
> > > >         {
> > > >             nBytesToRead = UINT(min(nBytesLeft, INT_MAX));
> > > >             ar.Read(pbData, nBytesToRead);
> > > >             pbData += nBytesToRead;
> > > >             nBytesLeft -= nBytesToRead;
> > > >             ar.Read(pbData, nBytesToRead);        // <<<<<<<< BUG
> > > >         }
> > > >    }
> > > > }

> > > > Could somebody advise me what to do about this???



Mon, 12 Jul 2004 02:45:26 GMT  
 Found bug in vc7 mfc code...
Michael,

In the ATLMFC source directory "Microsoft Visual Studio
.NET\vc7\atlmfc\src", there's a readme.txt and atlmfc.mak make file.
Use the VisualStudio command line prompt,  follow the instruction in the
readme file.

Please do not compile the recomplied MFC DLL as MFC70.DLL, use your own
internal name instead.

nmake /f atlmfc.mak MFC LIBNAME=<Your Lib Name>
This will build all the static, dll, ansi, UNICODE variations.

You can also go into the atlmfc.mak file to find the build line for your
specific configuration.

Anson


Quote:
> So - how can I rebuild the mfc library - I followed the instructions in
the
> readme located in the mfc source dir (which has worked for me on vs6) but
> then I have a lot of unresolved externals. Are there new switches???

> Michael



> > Michael,

> > You are absolute right, I apologize! Reading from CByteArray will
corrupt
> > the rest of your CArchive.

> > Anson



> > > Sorry to say that the bug not only happes as stated below but
allways -
> as
> > > the second read reads nBytesToRead bytes again!!!!

> > > regards,
> > > Michael



> > > > Michael,

> > > > You are correct, this is a bug that we'll fix in a future service
> pack.
> > > > However, you will only encounter this bug if your array size is
> greater
> > > than
> > > > INT_MAX. (Which was also not supported in VC6)

> > > > --
> > > > Anson Tsao
> > > > Visual C++ libraries team

> > > > Of course, this posting wouldn't be complete without a nice, juicy
> > > > disclaimer from our lawyers: This posting is provided "AS IS" with
no
> > > > warranties, and confers no rights. You assume all risk for your use.
?
> > > 2001
> > > > Microsoft Corporation. All rights reserved.


> message

> > > > > While trying to figure out a "File Format unknown" error in our
> > > > Application
> > > > > I found the following:

> > > > > (release version of visual studio dot net)

> > > > > File: ...\Microsoft Visual Studio
> .NET\Vc7\atlmfc\src\mfc\Array_b.cpp:

> > > > > void CByteArray::Serialize(CArchive& ar)
> > > > > {
> > > > >     UINT_PTR nBytesLeft;
> > > > >     UINT nBytesToWrite;
> > > > >     UINT nBytesToRead;
> > > > >     LPBYTE pbData;
> > > > >     ASSERT_VALID(this);
> > > > >     CObject::Serialize(ar);
> > > > >     if (ar.IsStoring())
> > > > >     {
> > > > >         ar.WriteCount(m_nSize);
> > > > >         nBytesLeft = m_nSize*sizeof(BYTE);
> > > > >         pbData = m_pData;
> > > > >         while(nBytesLeft > 0)
> > > > >         {
> > > > >             nBytesToWrite = UINT(min(nBytesLeft, INT_MAX));
> > > > >             ar.Write(pbData, nBytesToWrite);
> > > > >             pbData += nBytesToWrite;
> > > > >             nBytesLeft -= nBytesToWrite;
> > > > >         }
> > > > >     }
> > > > >     else
> > > > >     {
> > > > >         DWORD_PTR nOldSize = ar.ReadCount();
> > > > >         SetSize(nOldSize);
> > > > >         nBytesLeft = m_nSize*sizeof(BYTE);
> > > > >         pbData = m_pData;
> > > > >         while(nBytesLeft > 0)
> > > > >         {
> > > > >             nBytesToRead = UINT(min(nBytesLeft, INT_MAX));
> > > > >             ar.Read(pbData, nBytesToRead);
> > > > >             pbData += nBytesToRead;
> > > > >             nBytesLeft -= nBytesToRead;
> > > > >             ar.Read(pbData, nBytesToRead);        // <<<<<<<< BUG
> > > > >         }
> > > > >    }
> > > > > }

> > > > > Could somebody advise me what to do about this???



Mon, 12 Jul 2004 04:38:54 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. VC7 code generation bug?

2. BUG with VC7 RC1 with an MFC AppWizard generated CEditView project

3. possible bug in VC6, VC7, VC7.1

4. Possible bug in vc7.0 (and vc7.1)

5. VC7: BUG in IMPLEMENT_SERIAL (MFC)

6. Bug: VC7 MFC CByteArray::Serialize

7. my bug or VC7 bug ?

8. Can you help me to find bugs in this code

9. help me find the VC5.0 bug in this code

10. A Hard To Find Bug - Found

11. .Net VC7 project opened in VC6 can't find MSVCP70D.dll

12. drwtsn32 dont find pdb files generated by VC7

 

 
Powered by phpBB® Forum Software