[fdo-users] Issues mixing vc9/vc10 runtimes and FdoIoFileStream*
greg.boone at autodesk.com
Wed Mar 23 13:56:11 EDT 2011
Myself and Romy recently built the FDO binaries using vc9 and the FDO Unit Tests (and related CppUnit static lib) using vc10. This was done to mimic FDO usage within applications such as MapGuide, which may be compiled in vc10 in the near future.
Running unit tests on Win64/Release we see the following fatal error.
Microsoft Visual Studio C Runtime Library has detected a fatal error in UnitTest.exe.
> FDOCommon.dll!FdoIoFileStream::InitFileStatus() Line 394 C++
FDOCommon.dll!FdoIoFileStream::FdoIoFileStream() Line 78 C++
FDOCommon.dll!FdoIoFileStream::Create() Line 125 C++
UnitTest.exe!FdoIoTest::setUp() Line 49 C++
UnitTest.exe!CppUnit::TestCase::run() Line 27 C++
UnitTest.exe!CppUnit::TestSuite::run() Line 44 C++
UnitTest.exe!CppUnit::TextUi::TestRunner::runTest() Line 137 C++
UnitTest.exe!CppUnit::TextUi::TestRunner::runTestByName() Line 81 C++
UnitTest.exe!CppUnit::TextUi::TestRunner::run() Line 70 C++
UnitTest.exe!main() Line 91 C++
mFd = _fileno(mFp);
mFd = fileno(mFp);
struct stat fileStat;
if ( fstat(mFd, &fileStat) != 0 ) <<<<<<<<<<<<<<<<<<<<<<<<< Here <<<<<<<<<<<<<<<<<<
The problem is that in the unit test, the FILE* is opened using vc10, then in FDOCommon the vc9 version of fstat is used to access that pointer... and blammo, it dies.
// Create a file used for various file tests.
FILE* fp = fopen( "testFile.txt", "w" );
FdoIoFileStreamP fileStream = FdoIoFileStream::Create( fp );
fileStream->Write( (FdoByte*) "test file contents", 18 );
fileStream = NULL;
The problem API function is question is the following.
class FdoIoFileStream : public FdoIoStream
/// creates the stream around a C Runtime file stream.
/// \param fp
/// Input the file stream pointer.
/// Returns the created file stream.
FDO_API_COMMON static FdoIoFileStream* Create(FILE* fp);
My initial thought is to remove this method from the FDO API in 3.7.0.
The main purpose of the function is to allow an already opened FILE pointer (or stdin or stdout) to be wrapped in an FDO stream, usually for reading or writing XML. Streaming to or from stdout or stdin would likely be the most common case since the overload that takes a file name would more likely be used to access a disk file.
The only problem in removing it would be if a customer is calling it directly. I would almost say that this is unlikely but I suppose it is possible that someone is using it to stream XML from FDO to stdout.
Is there anyone using this method? Are there objections to removing it from the FDO API?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fdo-users