segmentation fault core dumped !!
hi guys,, though i am not getting any fault now luckily but i did not do anything just restarted my pc, but i often get segmentation fault , core dumped often,, according to me this is some memory issue which i don“t know how to debug,, can someone tell me how to debug this segmentation fault ??
thanks
code link -- https://pastebin.com/jwS39qyz
Asked by zubair on 2017-04-27 08:02:10 UTC
Comments
Did you write this code yourself? We can't possibly help debug without at least seeing a code snippet. Is this segfault coming from a ROS node that you didn't write? Which one, and how can we reproduce the issue?
Asked by jarvisschultz on 2017-04-27 09:30:27 UTC
I suggest editing your question to provide more detailed information. If you are looking for a general lesson on how to debug segfaults in code you've written, then this is probably not the right place to be asking that question.
Asked by jarvisschultz on 2017-04-27 09:32:01 UTC
hi, yes this is a rosnode,, which i am running and i cant paste the whole code here its exceeds to limit of comment.. but i am using opencv and my system is running on ros
Asked by zubair on 2017-04-27 09:33:32 UTC
and thus i dont know where i am getting segmentation fault,, i dont know which part of my code will be usefull to paste on here
Asked by zubair on 2017-04-27 09:34:33 UTC
I just closed this question because as it stands, we can't possibly help you. If you edit the question, I'll re-open it. Alternatively, you can just ask a new (hopefully more clearly written) question. Thanks!
Asked by jarvisschultz on 2017-04-27 09:34:49 UTC
You say you are using OpenCV, but you tagged PCL... which is it? I'd suggest using print statements and/or gdb to at least narrow down where your segfault is coming from.
Asked by jarvisschultz on 2017-04-27 09:36:40 UTC
ok, i cant paste my so long code on here,, well thanks i willl try if i can to rewrite my question.
Asked by zubair on 2017-04-27 09:37:21 UTC
If your code is really that long and there is some reason you can't include it in a question (I didn't think there were limits on that?) you can try including it in a pastebin or a gist. If your code is that long, people aren't as likely to help you because it will take significant time.
Asked by jarvisschultz on 2017-04-27 09:49:35 UTC
If you can narrow the segfault down to a specific function or snippet, people will be much more likely to be able to help.
Asked by jarvisschultz on 2017-04-27 09:50:31 UTC
https://pastebin.com/jwS39qyz this is my code .. have a look
Asked by zubair on 2017-04-27 09:51:48 UTC
The first major problem I see with your code is that the
blobDetectionCallback
callsgetXYZ
, but you cannot callgetXYZ
until you have received at least one PointCloud2 message in thedepthcallback
. I would wait to create theimage_transport::Subscriber
untilhasNewPcl
is true.Asked by jarvisschultz on 2017-04-27 12:07:44 UTC
This error is likely to cause segfaults basically every time you run your node. You are lucky that I took a few minutes to look at this. Learning how to debug is an important part of learning to program. People online are generally only going to help if you can ask specific, narrow questions.
Asked by jarvisschultz on 2017-04-27 12:08:55 UTC
I highly recommend learning how to use gdb to debug these types of problems yourself. Good luck with the rest of the development of this node!
Asked by jarvisschultz on 2017-04-27 12:09:40 UTC
but in my blobdetection callback i am never calling getXYZ, i am rather calling getdepthat .. which ia same function though as getXYZ, but returns me Z values,, also i didnt understood the image transport part of your answer
Asked by zubair on 2017-04-28 03:41:32 UTC
Sorry... I meant
getDepthAt
is called in theblobDetectionCallback
(which has the exact same problem asgetXYZ
).Asked by jarvisschultz on 2017-04-28 07:12:41 UTC