You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by "Henrik Nordberg (JIRA)" <ax...@ws.apache.org> on 2005/06/21 20:57:31 UTC

[jira] Created: (AXISCPP-707) Incorrect use of delete in AxisEngineException::processException()

Incorrect use of delete in AxisEngineException::processException()
------------------------------------------------------------------

         Key: AXISCPP-707
         URL: http://issues.apache.org/jira/browse/AXISCPP-707
     Project: Axis-C++
        Type: Bug
  Components: Server - Engine  
    Versions: current (nightly)    
 Environment: Windows XP Pro, VS2003
    Reporter: Henrik Nordberg
    Priority: Critical


There is a delete statement in AxisEngineException::processException() which 
has a couple of problems:
First, if you were supposed to delete the pointer passed in, delete[] should 
be used (in C++). But, at least in the case of the exception thrown when a 
library fails to load, a constant character pointer is passed in (in this 
case "") -- see this line in XMLParserFactory::loadLib():
throw AxisEngineException(SERVER_ENGINE_LOADING_PARSER_FAILED, 
PLATFORM_LOADLIB_ERROR);

Why not just use a const std::string& instead of char*?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-707) Incorrect use of delete in AxisEngineException::processException()

Posted by "Dushshantha Chandradasa (JIRA)" <ax...@ws.apache.org>.
    [ http://issues.apache.org/jira/browse/AXISCPP-707?page=comments#action_12314753 ] 

Dushshantha Chandradasa commented on AXISCPP-707:
-------------------------------------------------

I made a fix on this and tested the following scenarios. 

      1.  Exchanged the HTTPTransport.dll and HTTPChannel.dll file names 
      2.  Tested with a an older version of dll file i used AxisTransport.dll instead of HTTPTransport.dll
      3.  Tested with wrong endpoints of clients
      4.  Missing dll files

I got correct exception messages for the above test scenarios and server is working without any crash. 

Any ideas for more scenerios to be tested??



> Incorrect use of delete in AxisEngineException::processException()
> ------------------------------------------------------------------
>
>          Key: AXISCPP-707
>          URL: http://issues.apache.org/jira/browse/AXISCPP-707
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>  Environment: Windows XP Pro, VS2003
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Critical

>
> There is a delete statement in AxisEngineException::processException() which 
> has a couple of problems:
> First, if you were supposed to delete the pointer passed in, delete[] should 
> be used (in C++). But, at least in the case of the exception thrown when a 
> library fails to load, a constant character pointer is passed in (in this 
> case "") -- see this line in XMLParserFactory::loadLib():
> throw AxisEngineException(SERVER_ENGINE_LOADING_PARSER_FAILED, 
> PLATFORM_LOADLIB_ERROR);
> Why not just use a const std::string& instead of char*?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-707) Incorrect use of delete in AxisEngineException::processException()

Posted by "Henrik Nordberg (JIRA)" <ax...@ws.apache.org>.
    [ http://issues.apache.org/jira/browse/AXISCPP-707?page=comments#action_12314785 ] 

Henrik Nordberg commented on AXISCPP-707:
-----------------------------------------

The testing needs to include a scenario that causes this line
    throw AxisEngineException(SERVER_ENGINE_LOADING_PARSER_FAILED, PLATFORM_LOADLIB_ERROR); 
in the function XMLParserFactory::loadLib() in the file XMLParserFactory.cpp to be executed on the Win32 platform.

The fix should be to not delete the argument passed to Axis####Exception::processException(). The easiest way to do that is to change the argument type to "const std::string&". Note that this does not force people using the class to use std::string. They can still pass const char*. Also since this code seems to be the same for Axis exceptions, maybe it can be move to a base class.

The fact that the server is working without any crash (I assume you mean GPF or core dump) says little about the stability of the server. You need to run it with a memory checking tool. I recommend using Valgrind 2.4.0 (www.valgrind.org, download, ./configure, make, su, make install). I run it like this:
valgrind /usr/sbin/httpd -X -k start -f /home/henrik/httpd/httpd.conf

When you can run your tests without valgrind reporting any problems, then you can feel better about the quality of the code.


> Incorrect use of delete in AxisEngineException::processException()
> ------------------------------------------------------------------
>
>          Key: AXISCPP-707
>          URL: http://issues.apache.org/jira/browse/AXISCPP-707
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>  Environment: Windows XP Pro, VS2003
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Critical

>
> There is a delete statement in AxisEngineException::processException() which 
> has a couple of problems:
> First, if you were supposed to delete the pointer passed in, delete[] should 
> be used (in C++). But, at least in the case of the exception thrown when a 
> library fails to load, a constant character pointer is passed in (in this 
> case "") -- see this line in XMLParserFactory::loadLib():
> throw AxisEngineException(SERVER_ENGINE_LOADING_PARSER_FAILED, 
> PLATFORM_LOADLIB_ERROR);
> Why not just use a const std::string& instead of char*?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-707) Incorrect use of delete in AxisEngineException::processException()

Posted by "Henrik Nordberg (JIRA)" <ax...@ws.apache.org>.
    [ http://issues.apache.org/jira/browse/AXISCPP-707?page=comments#action_12314340 ] 

Henrik Nordberg commented on AXISCPP-707:
-----------------------------------------

This bug has two parts. The first part was fixed by using the correct delete operator (i.e., delete[] ). The second part is STILL A SERIOUS BUG:

In the function XMLParserFactory::loadLib() in the file XMLParserFactory.cpp, this snippet of code has a bug:

        throw AxisEngineException(SERVER_ENGINE_LOADING_PARSER_FAILED, PLATFORM_LOADLIB_ERROR);

PLATFORM_LOADLIB_ERROR is defined as a constant character pointer (which in this case is ""). But the semantics of the AxisEngineException requires that you pass in a char* and transfer ownership to AxisEngineException.

So you MUST NOT pass in PLATFORM_LOADLIB_ERROR as the second argument above. You MUST make a copy using operator new.

The problem is really the design of AxisEngineException. It should use std::string and not char*. It is too error prone (and is probably just one of the bugs that have or will result from it).

> Incorrect use of delete in AxisEngineException::processException()
> ------------------------------------------------------------------
>
>          Key: AXISCPP-707
>          URL: http://issues.apache.org/jira/browse/AXISCPP-707
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>  Environment: Windows XP Pro, VS2003
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Critical

>
> There is a delete statement in AxisEngineException::processException() which 
> has a couple of problems:
> First, if you were supposed to delete the pointer passed in, delete[] should 
> be used (in C++). But, at least in the case of the exception thrown when a 
> library fails to load, a constant character pointer is passed in (in this 
> case "") -- see this line in XMLParserFactory::loadLib():
> throw AxisEngineException(SERVER_ENGINE_LOADING_PARSER_FAILED, 
> PLATFORM_LOADLIB_ERROR);
> Why not just use a const std::string& instead of char*?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-707) Incorrect use of delete in AxisEngineException::processException()

Posted by "Dushshantha Chandradasa (JIRA)" <ax...@ws.apache.org>.
    [ http://issues.apache.org/jira/browse/AXISCPP-707?page=comments#action_12314845 ] 

Dushshantha Chandradasa commented on AXISCPP-707:
-------------------------------------------------

I applied some fixes to the issue AXISCPP-707 and committed the changes in to the CVS. 

 

I tested following scenarios to test this and the results seem to be OK. 

 

1. Exchanged the HTTPTransport.dll and HTTPChannel.dll file names 
      2. Tested with an older version of dll file I used AxisTransport.dll instead of HTTPTransport.dll 
      3. Tested with wrong endpoints of clients 
      4. Missing dll files   

      5. Missing AxisXMLParser.dll

 

I removed the delete operation from the method processException() and handled the NULL values for the arguments. 

 

Thank you very much Henrik for raising this issue and providing hints for the solution.



> Incorrect use of delete in AxisEngineException::processException()
> ------------------------------------------------------------------
>
>          Key: AXISCPP-707
>          URL: http://issues.apache.org/jira/browse/AXISCPP-707
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>  Environment: Windows XP Pro, VS2003
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Critical

>
> There is a delete statement in AxisEngineException::processException() which 
> has a couple of problems:
> First, if you were supposed to delete the pointer passed in, delete[] should 
> be used (in C++). But, at least in the case of the exception thrown when a 
> library fails to load, a constant character pointer is passed in (in this 
> case "") -- see this line in XMLParserFactory::loadLib():
> throw AxisEngineException(SERVER_ENGINE_LOADING_PARSER_FAILED, 
> PLATFORM_LOADLIB_ERROR);
> Why not just use a const std::string& instead of char*?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Reopened: (AXISCPP-707) Incorrect use of delete in AxisEngineException::processException()

Posted by "Samisa Abeysinghe (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-707?page=all ]
     
Samisa Abeysinghe reopened AXISCPP-707:
---------------------------------------


Henrik wrote:

There are a few things wrong here. First the two problems I am sure of:
 
A constant character array is passed to the ctor of AxisSoapException. This array is passed to the processException() method, which destroys it using operator delete. 
 
Dev team, please switch to using std::string instead of char*. You can still pass in constant char* if you have your arguments be const std::string&.
Currently there are many places in the code where "some constant" is passed to the ctors of various exceptions. Then those exceptions delete the strings and the server crashes (if we are lucky), as happened in this case.
 
I have reported this bug (which really is several bugs) to JIRA: http://issues.apache.org/jira/browse/AXISCPP-707
But only a very small part of the problem was addressed and then the bug was closed. This bug needs to be re-opened and fixed completely by removing the delete/delete[] in processException() and having the ctor take a const std::string& instead of char*. We also need to remove the places where new[] was used to create the argument to the ctor, but this is a small price to pay to avoid a crashing server.
 
The other aspect is the cause of your exception. I am not as sure about this one, but would guess that the client and server are using different SOAP encodings (Doc literal vs. RPC).
 
 - Henrik


> Incorrect use of delete in AxisEngineException::processException()
> ------------------------------------------------------------------
>
>          Key: AXISCPP-707
>          URL: http://issues.apache.org/jira/browse/AXISCPP-707
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>  Environment: Windows XP Pro, VS2003
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Critical

>
> There is a delete statement in AxisEngineException::processException() which 
> has a couple of problems:
> First, if you were supposed to delete the pointer passed in, delete[] should 
> be used (in C++). But, at least in the case of the exception thrown when a 
> library fails to load, a constant character pointer is passed in (in this 
> case "") -- see this line in XMLParserFactory::loadLib():
> throw AxisEngineException(SERVER_ENGINE_LOADING_PARSER_FAILED, 
> PLATFORM_LOADLIB_ERROR);
> Why not just use a const std::string& instead of char*?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (AXISCPP-707) Incorrect use of delete in AxisEngineException::processException()

Posted by "Dushshantha Chandradasa (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-707?page=all ]
     
Dushshantha Chandradasa closed AXISCPP-707:
-------------------------------------------

    Resolution: Fixed

Fixed

> Incorrect use of delete in AxisEngineException::processException()
> ------------------------------------------------------------------
>
>          Key: AXISCPP-707
>          URL: http://issues.apache.org/jira/browse/AXISCPP-707
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>  Environment: Windows XP Pro, VS2003
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Critical

>
> There is a delete statement in AxisEngineException::processException() which 
> has a couple of problems:
> First, if you were supposed to delete the pointer passed in, delete[] should 
> be used (in C++). But, at least in the case of the exception thrown when a 
> library fails to load, a constant character pointer is passed in (in this 
> case "") -- see this line in XMLParserFactory::loadLib():
> throw AxisEngineException(SERVER_ENGINE_LOADING_PARSER_FAILED, 
> PLATFORM_LOADLIB_ERROR);
> Why not just use a const std::string& instead of char*?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (AXISCPP-707) Incorrect use of delete in AxisEngineException::processException()

Posted by "Dushshantha Chandradasa (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-707?page=all ]
     
Dushshantha Chandradasa closed AXISCPP-707:
-------------------------------------------


Fixed

> Incorrect use of delete in AxisEngineException::processException()
> ------------------------------------------------------------------
>
>          Key: AXISCPP-707
>          URL: http://issues.apache.org/jira/browse/AXISCPP-707
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>  Environment: Windows XP Pro, VS2003
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Critical

>
> There is a delete statement in AxisEngineException::processException() which 
> has a couple of problems:
> First, if you were supposed to delete the pointer passed in, delete[] should 
> be used (in C++). But, at least in the case of the exception thrown when a 
> library fails to load, a constant character pointer is passed in (in this 
> case "") -- see this line in XMLParserFactory::loadLib():
> throw AxisEngineException(SERVER_ENGINE_LOADING_PARSER_FAILED, 
> PLATFORM_LOADLIB_ERROR);
> Why not just use a const std::string& instead of char*?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Resolved: (AXISCPP-707) Incorrect use of delete in AxisEngineException::processException()

Posted by "Dushshantha Chandradasa (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-707?page=all ]
     
Dushshantha Chandradasa resolved AXISCPP-707:
---------------------------------------------

    Resolution: Fixed

> Incorrect use of delete in AxisEngineException::processException()
> ------------------------------------------------------------------
>
>          Key: AXISCPP-707
>          URL: http://issues.apache.org/jira/browse/AXISCPP-707
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>  Environment: Windows XP Pro, VS2003
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Critical

>
> There is a delete statement in AxisEngineException::processException() which 
> has a couple of problems:
> First, if you were supposed to delete the pointer passed in, delete[] should 
> be used (in C++). But, at least in the case of the exception thrown when a 
> library fails to load, a constant character pointer is passed in (in this 
> case "") -- see this line in XMLParserFactory::loadLib():
> throw AxisEngineException(SERVER_ENGINE_LOADING_PARSER_FAILED, 
> PLATFORM_LOADLIB_ERROR);
> Why not just use a const std::string& instead of char*?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (AXISCPP-707) Incorrect use of delete in AxisEngineException::processException()

Posted by "Dushshantha Chandradasa (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-707?page=all ]

Dushshantha Chandradasa reassigned AXISCPP-707:
-----------------------------------------------

    Assign To: Dushshantha Chandradasa

> Incorrect use of delete in AxisEngineException::processException()
> ------------------------------------------------------------------
>
>          Key: AXISCPP-707
>          URL: http://issues.apache.org/jira/browse/AXISCPP-707
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>  Environment: Windows XP Pro, VS2003
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Critical

>
> There is a delete statement in AxisEngineException::processException() which 
> has a couple of problems:
> First, if you were supposed to delete the pointer passed in, delete[] should 
> be used (in C++). But, at least in the case of the exception thrown when a 
> library fails to load, a constant character pointer is passed in (in this 
> case "") -- see this line in XMLParserFactory::loadLib():
> throw AxisEngineException(SERVER_ENGINE_LOADING_PARSER_FAILED, 
> PLATFORM_LOADLIB_ERROR);
> Why not just use a const std::string& instead of char*?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira