473,385 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

stack trace points to uninit data in below routine

365 100+
I have memory leak issue, I found from stack trace that "sendto" points to uninitialised data in the below routine, does vsnprintf cause this error?


syscall param socketcall.sendto(msg) points to uninitialised bytes(s)
at 0x43B731E: sendto (in /lib/libpthread-2.5.so)
by 0x439A019: adpModuleDebug (in /pfrm/lib/libi386adaptos.so)

Expand|Select|Wrap|Line Numbers
  1. f (!pEntry || (pEntry->debugLevel & debugLevel))
  2.         {
  3.         int len;
  4.         char buf[256];
  5.  
  6.         len = sprintf(buf, "%s:%d:", function, line);
  7.         va_start (arg, pszFormat);
  8.         vsnprintf (&buf[len], 255-len, pszFormat, arg);
  9.         va_end (arg);
  10.         printf ("%s", buf);
  11.         }
Jan 19 '10 #1
7 2143
RedSon
5,000 Expert 4TB
Look, its not very difficult to put your code inside of code tags. You've posted over 200 messages to this board, you should know by now.

The code tag button is the little one that looks like a hash mark. USE IT!
Jan 19 '10 #2
donbock
2,426 Expert 2GB
I don't see anything in the code snippet that involves threads or sockets. Do you use threads or sockets elsewhere in your program?

Notice that sprintf returns a negative value if it fails. As a general principle you should trap this error return before using the return value to index into the buffer. This is unlikely to be your problem.

By the way, as a general principle it would have been better to use snprintf rather than sprintf. This is unlikely to be your problem. If you use snprintf then not only might the return value be negative, it might also be larger than the size of your buffer -- you should trap that condition too.
Jan 19 '10 #3
tvnaidu
365 100+
sorry for that, it won't repeat again
Jan 19 '10 #4
tvnaidu
365 100+
I compiled with -g option, basically there is one IOCTL call in the above code with compilation switch, whcih calls sendto call, I am adding that code below:

[ctags]
Expand|Select|Wrap|Line Numbers
  1.     UMI_REQ_INFO *  pUmiReq;
  2.     unsigned int    reqBufSize;
  3.  
  4.  
  5.  pUmiReq = (UMI_REQ_INFO *)pBuf;
  6.         pUmiReq->cmd    = cmd;
  7.         pUmiReq->srcId  = pSrcCtx->myId;
  8.         pUmiReq->reqOpt = reqOpt;
  9.         pUmiReq->reqId  = reqId;
  10.         pUmiReq->req    = 1;
  11.  
  12.         if (sendto (pSrcCtx->sockFd, pUmiReq, reqBufSize,
  13.                     0, (struct sockaddr *) &destId, sizeof(UMI_COMP_ID)) == -1)
  14.             {
[/ctags]
Jan 19 '10 #5
RedSon
5,000 Expert 4TB
The code tags are [ code] and [/code]

not "ctags". Use the little hash button it will add them in for you.
Jan 19 '10 #6
tvnaidu
365 100+
thank you sir, I did long back, forgot
Jan 19 '10 #7
tvnaidu
365 100+
I did memset pUmiReq to zero before filling stuff, but still it didn't fix "uninitialised data", any idea what is the issue with the above sendto call?. thanks.
Jan 20 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Andrew | last post by:
Last night I was reading about implementing my own stack. The example given pushes items on and off the stack at the start and end of each procedure (ie. in a std module). What's not so clear is...
18
by: IMSHURKKPWII | last post by:
Hi all, I am confused about the methods by which C passes things to other routines. If I have a routine, void rt( , , ...); Then I know that the process to call this function is this: ...
4
by: anonymous | last post by:
Thanks your reply. The article I read is from www.hakin9.org/en/attachments/stackoverflow_en.pdf. And you're right. I don't know it very clearly. And that's why I want to understand it; for it's...
13
by: Ben R. Bolton | last post by:
The documentation indicates that the threads "default stack size" is 1MB. The work "default" implies that it can be changed. Is it possible to change the StackSize in .NET? If so how? Is it...
2
by: RC | last post by:
I have implemented an error logging routine that writes out the stack trace (associated with the Exception object). It tells me the exact line(s) of code that lead up to the Exception. Example:...
8
by: Vishal | last post by:
Hello, I have uploaded my website from VS to my server and unfortunaly there is an error when I visit the website. However the stack trace of the error still points to my local directory. It...
24
by: John | last post by:
I know this is a very fundamental question. I am still quite confused if the program call stack stack should always grows upwards from the bottom, or the opposite, or doesn't matter?? That means...
5
by: Mr. SweatyFinger | last post by:
WHY CAN'T THE CLOWN -HOLES WHO WROTE ASP.NET PROVIDE AN ERROR LINE NUMBER??? HONEST TO SH@THOLE PETE Server Error in '/New Folder (7)' Application....
7
by: David T. Ashley | last post by:
Is there any portable method for identifying the caller of a function, its caller, and so on, at runtime, without using a debugger? Clearly, one can dissect the stack frame and trace it back. ...
9
by: coder_lol | last post by:
Thanks everybody for helping me with the Syntax confusion! The implicit conversion stuff really got me :) I have one more question... Array<int32ia; Does the above use the default...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.