Hi all,

it took me a long time to build Podofo on Sun Solaris using the native Sun 
Studio compiler.
For several reasons I  could not use gcc, where everything worked fine.

With Sun Studio I ran into SIGSEGV crash (helloworld example).

As helloword sample runs fine on other machines and compilers I first 
blamed  Sun  Studio for the crash.
But after some investigations, I think, that the problem is inside Podofo.

The problem is inside PdfVariant, 
the member Variable m_Data.pData is of type PdfDataType* .

PdfDataType is an interface for real datatype classes, such as PdfArray.
Any  real datatype class has multiple inheritance (I like Java!),.
PdfArray is derived from vector and PdfDataType.

In PdfVariant.cpp , operator=, m_Data.pData is assigned as

       case ePdfDataType_Array:
        {
            if( rhs.m_Data.pData ) 
                m_Data.pData = new PdfArray( 
*(static_cast<PdfArray*>(rhs.m_Data.pData)) );
            break;
        }

As pData is of type PdfDataType, a pointer to the PdfDataType part of the 
PdfArray is assigned.
In the debugger, if the code is slightly changed
   PdfArray pNew = new PdfArray( 
*(static_cast<PdfArray*>(rhs.m_Data.pData)) );
   m_Data.pData = pNew;

Under dbx you see: m_Data.pData is NOT equal pNew, but  pNew + (offset 
PdfDataType in PdfArray).

Later, going back from m_Data.pData to PdfArray in PdfVariant.h,
a reinterpret_cast is used and the pointer is unchanged in assigment.

PdfArray & PdfVariant::GetArray_NoDL()
{
    // Test against eDataType directly not GetDataType() since
    // we don't want to trigger a delayed load (and if required one has
    // already been triggered).
    if( m_eDataType != ePdfDataType_Array )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
    }
    return *(reinterpret_cast<PdfArray* const>(m_Data.pData));
}

The reinterpret_cast is causing the crash as pData points to to the 
PdfDataype part, not to PdfArray.
If the vector part of the PdfArray is accessed, the crash occurs.

My suggestion is to just remove the reinterpret_cast, so that assignment 
and back assignment are symmetric.

After replacing the reinterpret_cast (on severall occurrences) in 
PdfVariant.h, for example

   //  return *(reinterpret_cast<PdfArray* const>(m_Data.pData));
   return *(PdfArray*)m_Data.pData;

everything worked well, on Sun Studio compiler and  several other 
platforms.

Why did the problem not occur in other environments?
Probably because the class layout  is different, so that the PdfDatatype 
part in compound objects comes
always first (offset 0).
Then, the reinterpret_cast does no harm.

friendly regards
Hartmut Haas

TONBELLER AG 
Werner-von-Siemens-Str. 2 
D-64625 Bensheim  
Germany 

www.tonbeller.com 

Register Court: District Court Darmstadt / Registration: HRB 21474 
Managing Board: Rutger Hetzler (CEO), Sebastian Hetzler, Torsten Mayer 
Chairman of the Supervisory Board: Rüdiger Brand 
This message is for the designated recipient only and may contain privileged, 
proprietary, or otherwise private information. If you have received it in 
error, please notify the sender immediately and delete the original. Any 
unauthorised copying or dissemination of this message is strictly prohibited.  
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten 
haben, informieren Sie bitte sofort den Absender und vernichten Sie diese 
E-Mail. Das unerlaubte Kopieren sowie die Weitergabe dieser E-Mail ist nicht 
gestattet.  
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to