WSD Printer Client based on WS4D-gSOAP stack crashing

74 views
Skip to first unread message

Raveesh Kumar B

unread,
Jun 22, 2009, 9:57:51 AM6/22/09
to ws4d-gs...@googlegroups.com, ravees...@gmail.com
Hi,

I am developing WSD Printer Client using WS4D-gSOAP stack(I am using the latest trunk sources) on Windows  platform using Visual Studio 2008.
I have developed the Client based on Air Conditioner example given as sample program in the tool kit.

The code compiles and runs fine as expected in with the default VC options generated by Cmake and compiled as C Code.(i.e "Project->Properties->Configuration Properties->C/C++->Advanced->Compile As->Compile as C code(/TC)") .

As I am planning to extend my Printer client APIs with C++, I had to change the "Project settings" to "Compile as C++ code" option.
(i.e "Project->Properties->Configuration Properties->C/C++->Advanced->Compile As->Compile as C++ code(/TP)") ). But with this,
program compiles but crashes at runtime at the following statement.
XAddrs = (char *) dpws_resolve_addr(&dpws, &device, NULL, 10000);

Following is the call stack at the time of crash

    wsd-client.exe!soap_serialize_string(soap * soap=0x00e610b8, char * const * a=0x00000123)  Line 12240 + 0x5 bytes    C
     wsd-client.exe!soap_serialize_wsa__Relationship(soap * soap=0x00e610b8, const wsa__Relationship * a=0x00000123)  Line 8758 + 0xd bytes    C
     wsd-client.exe!soap_serialize_PointerTo_wsa__RelatesTo(soap * soap=0x00e610b8, wsa__Relationship * const * a=0x00290004)  Line 10753 + 0xf bytes    C
     wsd-client.exe!soap_serialize_SOAP_ENV__Header(soap * soap=0x00e610b8, const SOAP_ENV__Header * a=0x00290000)  Line 4249 + 0x10 bytes    C
     wsd-client.exe!soap_serializeheader(soap * soap=0x00e610b8)  Line 27 + 0x13 bytes    C
     wsd-client.exe!soap_send___wsd__Resolve(soap * soap=0x00e610b8, const char * soap_endpoint=0x004f40d0, const char * soap_action=0x004f26f4, wsd__ResolveType * wsd__Resolve=0x00e60fe0)  Line 243 + 0x9 bytes    C
     wsd-client.exe!wsd_resolve_async(soap * soap=0x00e610b8, const char * MsgId=0x0029a250, const char * Address=0x0029a3d8, unsigned long timeout=10000, ws4d_alloc_list_s * alist=0x00e610a8)  Line 1675 + 0x14 bytes    C
     wsd-client.exe!ws4d_discoveryctx_resolve(dpws_probectx * ctx=0x00e6108c, unsigned long timeout=10000)  Line 233 + 0x24 bytes    C
     wsd-client.exe!dpws_resolve_addr(dpws_s * dpws=0x00e8fdf8, ws4d_epr * epr=0x00e8fecc, ws4d_tc_int * tc=0x00298e48, unsigned long timeout=10000)  Line 1585 + 0x10 bytes    C

Following is the function in dpwsC.c, where the crash occurs.

SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap *soap, char *const*a)
{
    soap_reference(soap, *a, SOAP_TYPE_string);
}

In case of C code, the pointer "a" is NULL.
In case of C++ code, the pointer "a" is filled with some junk address. So, the program crashes saying Access violation reading location <junk address>, as it is trying deference pointer "a" in soap_reference()

Could you please guide me in knowing, what is wrong here or what are the things I need to take care when developing WSD Printer Client in C++?.

Thanks
Raveesh

Elmar Zeeb

unread,
Jun 22, 2009, 11:08:33 AM6/22/09
to ws4d-gs...@googlegroups.com, ravees...@gmail.com
Raveesh Kumar B schrieb:
Hi,

I am developing WSD Printer Client using WS4D-gSOAP stack(I am using the latest trunk sources) on Windows  platform using Visual Studio 2008.
I have developed the Client based on Air Conditioner example given as sample program in the tool kit.

The code compiles and runs fine as expected in with the default VC options generated by Cmake and compiled as C Code.(i.e "Project->Properties->Configuration Properties->C/C++->Advanced->Compile As->Compile as C code(/TC)") .

As I am planning to extend my Printer client APIs with C++, I had to change the "Project settings" to "Compile as C++ code" option.
(i.e "Project->Properties->Configuration Properties->C/C++->Advanced->Compile As->Compile as C++ code(/TP)") ). But with this,
program compiles but crashes at runtime at the following statement.
XAddrs = (char *) dpws_resolve_addr(&dpws, &device, NULL, 10000);
You should not compile the whole project with c++ but only your own files. If you call them .cc or .cpp (don't know which is correct) cmake or vc should call the correct compiler.


Following is the call stack at the time of crash

    wsd-client.exe!soap_serialize_string(soap * soap=0x00e610b8, char * const * a=0x00000123)  Line 12240 + 0x5 bytes    C
     wsd-client.exe!soap_serialize_wsa__Relationship(soap * soap=0x00e610b8, const wsa__Relationship * a=0x00000123)  Line 8758 + 0xd bytes    C
     wsd-client.exe!soap_serialize_PointerTo_wsa__RelatesTo(soap * soap=0x00e610b8, wsa__Relationship * const * a=0x00290004)  Line 10753 + 0xf bytes    C
     wsd-client.exe!soap_serialize_SOAP_ENV__Header(soap * soap=0x00e610b8, const SOAP_ENV__Header * a=0x00290000)  Line 4249 + 0x10 bytes    C
     wsd-client.exe!soap_serializeheader(soap * soap=0x00e610b8)  Line 27 + 0x13 bytes    C
     wsd-client.exe!soap_send___wsd__Resolve(soap * soap=0x00e610b8, const char * soap_endpoint=0x004f40d0, const char * soap_action=0x004f26f4, wsd__ResolveType * wsd__Resolve=0x00e60fe0)  Line 243 + 0x9 bytes    C
     wsd-client.exe!wsd_resolve_async(soap * soap=0x00e610b8, const char * MsgId=0x0029a250, const char * Address=0x0029a3d8, unsigned long timeout=10000, ws4d_alloc_list_s * alist=0x00e610a8)  Line 1675 + 0x14 bytes    C
     wsd-client.exe!ws4d_discoveryctx_resolve(dpws_probectx * ctx=0x00e6108c, unsigned long timeout=10000)  Line 233 + 0x24 bytes    C
     wsd-client.exe!dpws_resolve_addr(dpws_s * dpws=0x00e8fdf8, ws4d_epr * epr=0x00e8fecc, ws4d_tc_int * tc=0x00298e48, unsigned long timeout=10000)  Line 1585 + 0x10 bytes    C

Following is the function in dpwsC.c, where the crash occurs.

SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_string(struct soap *soap, char *const*a)
{
    soap_reference(soap, *a, SOAP_TYPE_string);
}

In case of C code, the pointer "a" is NULL.
In case of C++ code, the pointer "a" is filled with some junk address. So, the program crashes saying Access violation reading location <junk address>, as it is trying deference pointer "a" in soap_reference()

Could you please guide me in knowing, what is wrong here or what are the things I need to take care when developing WSD Printer Client in C++?.
C++ support is broken at the moment. This has several technical and non-technical reasons: In most header files i added a statement like:
#ifdef __cplusplus
extern "C"
{
#if 0
}
#endif
#endif
at the beginning at the file and
#ifdef __cplusplus
#if 0
{
#endif
}
#endif
at the end.
But this is not consistent at all header files.

I don't have enough time to fix this at the moment but ws4d-gsoap is open for contributions :-)

Regards,
Elmar Zeeb

Thanks
Raveesh




-- 
*******************************************************************************
  Dipl.-Inf. Elmar Zeeb
  Universität Rostock, Fakultät f. Informatik und Elektrotechnik
  Institut f. Angewandte Mikroelektronik und Datentechnik
  University of Rostock, Faculty of CS and EE
  Institute of Applied Microelectronics and Computer Engineering,
  18051 Rostock
  Deutschland/Germany
  Tel. : ++49 (0)381 498 - 7262
  Fax  : ++49 (0)381 498 - 7252
  Email: elmar...@uni-rostock.de
  www  : http://www.imd.uni-rostock.de/, http://www.ws4d.org/
*******************************************************************************
Message has been deleted

Raveesh Kumar B

unread,
Jun 24, 2009, 3:02:40 AM6/24/09
to elmar...@uni-rostock.de, ws4d-gs...@googlegroups.com
Thanks Elmar for your response.
I compiled my project files in C++ and I am calling WS4D-gSOAP stack functions using C interfaces.
It runs fine and does not crash at dpws_resolve_addr()

Thanks
Raveesh

Raveesh Kumar B

unread,
Jun 24, 2009, 3:22:42 AM6/24/09
to ws4d-gs...@googlegroups.com
Thanks Elmar for your response.
I compiled my project files in C++ and I am calling WS4D-gSOAP stack functions using C interfaces.
It runs fine and does not crash at dpws_resolve_addr().

Thanks
Raveesh

On Mon, Jun 22, 2009 at 8:38 PM, Elmar Zeeb <elmar...@uni-rostock.de> wrote:

Elmar Zeeb

unread,
Jun 24, 2009, 3:53:37 AM6/24/09
to Raveesh Kumar B, ws4d-gs...@googlegroups.com
Raveesh Kumar B schrieb:
Thanks Elmar for your response.
I compiled my project files in C++ and I am calling WS4D-gSOAP stack functions using C interfaces.
It runs fine and does not crash at dpws_resolve_addr()
So you wrote a Airconditioner-Example in C++? I often get questions about C++ support and would be glad to include your C++ Airconditioner-Example as C++-example in ws4d-gsoap. Is this possible?

Raveesh Kumar B

unread,
Jun 24, 2009, 4:57:57 AM6/24/09
to ws4d-gs...@googlegroups.com, Elmar Zeeb
Hi Elmar,

Sorry, I did not write Airconditioner example in C++ but was developing a printer client.

What I did can be summed as : I created a static C library(.lib), containing interface functions, which call WS4D-GSoap functions. I call these interface functions in C, from my C++ code.

Thanks
Raveesh
Reply all
Reply to author
Forward
0 new messages