Invalid Pointer Xcode 8 - c++

I am developing an application in Xcode 8.1. It is used to find printers inside the network. It uses cpp files also for printer searching. But i got one error
malloc: *** error for object 0x6080000099f0: Invalid pointer dequeued from free list
*** set a breakpoint in malloc_error_break to debug
I enabled zombie to catch this exception but fails.Also i added malloc error break but fails. Added try catch but it shows error break inside try block. Please help me how to catch this exception and if someone already face this issue please help me how to solve this.

Related

R session crashes when using .so file that uses OpenBLAS

I tried to write some simple matrix calculation code in c++ with OpenBLAS and then import my program into R. I did not use any Rcpp related things.
When compiled alone, the c++ program works perfectly. When I commented the few lines with OpenBLAS functions, used R CMD SHLIB to compile it and used dyn.load to import the .so file into my R program, R works fine.
However, if I uncommented the OpenBLAS-involved part, R crashes every time. When run from terminal, the following error message was reported:
R(90544,0x16bd7f000) malloc: Heap corruption detected, free list is damaged at 0x6000033d0620
*** Incorrect guard value: 0
R(90544,0x16bd7f000) malloc: *** set a breakpoint in malloc_error_break to debug
zsh: abort R
Also, when I run only with a single line of OpenBLAS command, there was the following error:
*** caught segfault ***
address 0x60012e797320, cause 'invalid permissions'
Do I miss something? I do need some help since I struggled with this for a long time. Thank you guys.
I found a way round. I directly use the LAPACK used by R and followed the procedure stated here medium.com/#shiansu/calling-blas-in-r-the-hard-way-da90e0206d99. With some slight adaption, my code could finally work.

How to catch the c/c++ malloc error?

I have a Java app which run a c++ application which calls my odbc driver and sometimes I receive the error ilke
myapp(601,0x7000017a5000) malloc: *** error for object 0x7fc645161a10: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
I cannot use gdb or lldb because it occurs inside of mydriver.so module.
Is it possible to catch this error in the code?
Or somehow redefine the malloc_error_break and trap the error inside it?
How to detect what is the object ?
Is this an error of application which calls odbc or in my odbc code?

Unhandled microsoft c++ exception cv exception at memory location

I currently developped a project with VS and OpenCV on my x64 computer and i've a problem with this line:
model->train(image, labels);
image and labels are not empty but i've got this error:
Unhandled exception at at 0x774FC42D in facerec_video.exe: Microsoft C++ exception: cv::Exception at memory location 0x0015EF38.
If i click "continue", program continue and works.
Furthermore, if i set a breakpoint on this line and do a step by step, error message doesn't appear and program works too.
How to resolve this problem ?
Thanks

The eclipse synchronized C/C++ project fails to synchronize

I tried to create synchronized C/C++ project for linux kernel (very big project) with Eclipse kepler, however project synchronization always fails to start between local and remote host (initial files on local host).
I've got the following exception:
An internal error occurred during: "Remote Synchronization". Exception
caught during execution of add command.
However there is no issue if I create synchronized project for small project.
Does any one has an idea what cause this issue?
exception stack trace:
!ENTRY org.eclipse.core.jobs 4 2 2013-12-27 11:12:07.376
!MESSAGE An internal error occurred during: "Remote Synchronization".
!STACK 0
org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of add command
at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:208)
at org.eclipse.ptp.internal.rdt.sync.git.core.GitRemoteSyncConnection.doCommit(GitRemoteSyncConnection.java:577)
at org.eclipse.ptp.internal.rdt.sync.git.core.GitRemoteSyncConnection.buildRepo(GitRemoteSyncConnection.java:242)
at org.eclipse.ptp.internal.rdt.sync.git.core.GitRemoteSyncConnection.<init>(GitRemoteSyncConnection.java:167)
at org.eclipse.ptp.internal.rdt.sync.git.core.GitSyncService.getSyncConnection(GitSyncService.java:211)
at org.eclipse.ptp.internal.rdt.sync.git.core.GitSyncService.getMergeConflictFiles(GitSyncService.java:174)
at org.eclipse.ptp.internal.rdt.sync.git.core.GitSyncService.synchronize(GitSyncService.java:399)
at org.eclipse.ptp.internal.rdt.sync.core.SyncRunner.synchronize(SyncRunner.java:38)
at org.eclipse.ptp.rdt.sync.core.SyncManager$SynchronizeJob.run(SyncManager.java:79)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: org.eclipse.jgit.errors.LockFailedException: Cannot lock /home/oussama/devel/mylinux/.ptp-sync/index
at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:224)
at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:301)
at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:267)
at org.eclipse.jgit.lib.Repository.lockDirCache(Repository.java:1049)
at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:138)
... 9 more
Judging from your stack trace it appears that EGit is choking on an orphaned lock file:
Cannot lock /home/oussama/devel/mylinux/.ptp-sync/index
Look for /home/oussama/devel/mylinus/.ptp-sync/index.lock. If it exists, delete it and try synchronizing again. See also, this Eclipse bug.

Aborted core dumped C++

I have a large C++ function which uses OpenCV library and running on Windows with cygwin g++ compiler. At the end it gives Aborted(core dumped) but the function runs completely before that. I have also tried to put the print statement in the end of the function. That also gets printed. So I think there is no logical bug in code which will generate the fault.
Please explain.
I am also using assert statements.But the aborted error is not due to assert statement. It does not say that assertion failed. It comes at end only without any message.
Also the file is a part of a large project so I cannot post the code also.
gdb results:
Program received signal SIGABRT, Aborted.
0x7c90e514 in ntdll!LdrAccessResource () from /c/WINDOWS/system32/ntdll.dll
It looks like a memory fault (write to freed memory, double-free, stack overflow,...). When the code can be compiled and run under Linux you can use valgrind to see if there are memory issues. Also you can try to disable parts of the application until the problem disappears, to get a clue where the error happens. But this method can also give false positives, since memory related bugs can cause modules to fail which are not the cause of the error. Also you can run the program in gdb. But also here the position the debugger points to may not be the position where the error happened.
You don't give us much to go on. However, this looks like you are running into some problem when freeing resources. Maybe a heap corruption. Have you tried running it under gdb and then looking where it crashes? Also, check if all your new/delete calls match.
Load the core dump together with the binary into gdb to get an idea at which location the problem list. Command line is:
gdb <path to the binary> <path to the core file>
For more details on gdb see GDB: The GNU Project Debugger.
Run it through AppVerifier and cdb.
E.g.
cdb -xd sov -xd av -xd ch <program> <args>