ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » User Exits » How to catch Null pointer invocations

Post new topic  Reply to topic
 How to catch Null pointer invocations « View previous topic :: View next topic » 
Author Message
ktg
PostPosted: Wed Jul 23, 2008 10:58 pm    Post subject: How to catch Null pointer invocations Reply with quote

Centurion

Joined: 09 Jan 2006
Posts: 138
Location: India

Hi All,

We are writing an API exit to catch all null pointer invocation by applications.
For example, application should issue MQPUT in the following format (correct way)
MQPUT(Hcon, /* connection handle */
Hobj, /* object handle */
&md, /* message descriptor */
&pmo, /* default options (datagram) */
messlen, /* message length */
buffer, /* message buffer */
&CompCode, /* completion code */
&Reason); /* reason code */

In case, if application passes NULL for any parameter, API exit need to log that error. For example passing pointer to message descriptor as null
MQPUT(Hcon, /* connection handle */
Hobj, /* object handle */
NULL, /* message descriptor */
&pmo, /* default options (datagram) */
messlen, /* message length */
buffer, /* message buffer */
&CompCode, /* completion code */
&Reason); /* reason code */

How can we catch this error.
In PutBefore entry point, there will be
void MQENTRY PutBefore ( PMQAXP pEP
, PMQAXC pEC
, PMQHCONN pHconn
, PMQHOBJ pHobj
, PPMQMD ppMsgDesc
, PPMQPMO ppPutMsgOpts
, PMQLONG pBufferLength
, PPMQVOID ppBuffer
, PMQLONG pCompCode
, PMQLONG pReason
)

if (ppMsgDesc == NULL || *ppMsgDesc == NULL)
is not catching the error.

if (ppMsgDesc == NULL || *ppMsgDesc == NULL || **ppMsgDesc == NULL ) gives compilation error (type mismatch)

What could be done?

Thanks in advance.

Regards,
Kalpana
Back to top
View user's profile Send private message AIM Address
David.Partridge
PostPosted: Wed Jul 23, 2008 11:35 pm    Post subject: Reply with quote

Master

Joined: 28 Jun 2001
Posts: 249

Never mind the C semantics, what are you hoping to achieve?

What could you do in an API exit that would "do the right thing" in all (or even a small fraction of) cases - exit code can't be prescient or read the mind of the developer to change the invocation parameters so that the exit acts as a "Do what I meant".

If an application is going to crash and burn because a developer hasn't used tools such as "Lint" or even old fashioned desk checking, then it will crash and burn. If the developer is passing null pointers to the MQI, there are probably other fundamental errors in the code as well.

No amount of code in an API exit will protect them from that, and IMHO, nor should you attempt it.
_________________
Cheers,
David C. Partridge
Back to top
View user's profile Send private message
ktg
PostPosted: Thu Jul 24, 2008 12:59 am    Post subject: Reply with quote

Centurion

Joined: 09 Jan 2006
Posts: 138
Location: India

I was wrong when I said
Quote:
"We are writing an API exit to catch all null pointer invocation by applications"

Actually, we have an API exit for some other purpose. It was giving wrong results in production site.
Later it was found that, the wrong results were because of an MQPUT call with MQMD as NULL parameter. That situation was arising because of a bug in MQ. It was the report by team at production site.
Here, in the development environment we could not simulate the same problem. But, we were asked to make the API exit defensive against NULL pointer invocations.
Hence.........

Thanks,
Kalpana
Back to top
View user's profile Send private message AIM Address
fjb_saper
PostPosted: Thu Jul 24, 2008 10:39 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

You can't fix that. What you can fix is force production to use the right version of MQ... i.e. the one you and QA tested with and did not have the problem.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » User Exits » How to catch Null pointer invocations
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.