ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi all,
I'm working on some code which suddenly is causing a segmentation on vsprintf. This was working before, so I cut and pasted some code from vsprintf function at the cplusplus site and even this is causing a problem. Anyway the example is
Sure - start debugging. Either by inserting diagnostic prints or by using 'gdb'. For the latter perform WEB search on
gdb segmentation fault tutorial
- for example, first match from Yahoo.
...
Does your compilation command line have '-Wall -Wextra' ? If doesn't, add the items and first make sure there are no warnings.
==7566== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 65 from 1)
==7566== malloc/free: in use at exit: 0 bytes in 0 blocks.
==7566== malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
==7566== For counts of detected errors, rerun with: -v
==7566== All heap blocks were freed -- no leaks are possible.
also it runs on another PC running Ubuntu, so I'm assuming that on my Debian laptop it's either the hardware or a deb./gcc version fault
it runs on another PC running Ubuntu, so I'm assuming that on my Debian laptop it's either the hardware or a deb./gcc version fault
A hardware fault is extremely unlikely based on the info you have posted in this thread. A library version incompatibility is fairly unlikely, but should be considered.
If a program runs without symptoms, that never proves the program is correct. If the same program fails on a different computer, that doesn't indicate anything is wrong with the computer where the failure occurred. Bugs in programs often hide (run with no symptoms). A bug may be revealed by a change that has no direct relationship to the bug.
So far you haven't really told us what you're actually doing.
Did you duplicate the malfunction with a tiny program similar to the one ntubski posted? Or is the failure only occurring inside a more complicated program (too big for you to post the whole thing)?
Quote:
Originally Posted by knobby67
gdb shows a segmentation crash on vsprintf.?
Quote:
Originally Posted by Sergei Steshenko
start debugging. Either by inserting diagnostic prints or by using 'gdb'.
If I were debugging this, I could make direct progress from the point that gdb shows a seg fault in vsprintf. But I would do that by looking at the cpu registers and stack and disassembly of the code at the point of failure. For someone who doesn't know x86 assembler, there may be no clean way forward using gdb. IIUC, the failure is seen in a library routine and there is nothing obviously wrong at the source level with the parameters passed to that library routine. That is a very hard situation to diagnose if you don't know assembler.
When I suspect a library version incompatibility, I use the ldd command on the executable and look at the results to see if anything looks suspicious. You might want to post the results of ldd, because I can't really tell you what to interpret as "suspicious" by yourself, but maybe some expert here seeing your ldd output would spot a possible problem.
If you know gdb commands but not x86 assembler, you could post the registers, stack and disassembly at the point of failure. I might make a good guess at the problem based on just those.
...
If I were debugging this, I could make direct progress from the point that gdb shows a seg fault in vsprintf. But I would do that by looking at the cpu registers and stack and disassembly of the code at the point of failure. For someone who doesn't know x86 assembler, there may be no clean way forward using gdb. ...
'glibc' source is readily available. 'vsprintf' source can be, for example, copy-pasted into the program to be debugged, so debugging at "C" (rather than assembly) level will become possible.
But maybe the problem is not that deep, i.e. maybe some of the arguments/variable are corrupted - this can be seen with 'gdb' ot diagnostic prints.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.