www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Any tools to track heap/stack corruptions?

reply JN <666total wp.pl> writes:
I am dealing with some nasty issue in my code. Basically random 
unrelated lines of code are crashing with access violations, and 
if I switch from dmd to ldc the crash goes away, or crash comes 
back, or it crashes in a different spot. Seems like I am 
corrupting some memory somewhere (I interact a lot with C 
libraries). Do you know of any tools I could use to try to narrow 
it down?

I've used Application Verifier but so far it didn't point me to 
anything specific.
Feb 03 2021
next sibling parent reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Wednesday, 3 February 2021 at 14:00:23 UTC, JN wrote:
 I am dealing with some nasty issue in my code. Basically random 
 unrelated lines of code are crashing with access violations, 
 and if I switch from dmd to ldc the crash goes away, or crash 
 comes back, or it crashes in a different spot. Seems like I am 
 corrupting some memory somewhere (I interact a lot with C 
 libraries). Do you know of any tools I could use to try to 
 narrow it down?

 I've used Application Verifier but so far it didn't point me to 
 anything specific.
I don't see where exactly you're having wierd issues. Can you use a debugger? https://wiki.dlang.org/Debuggers Or dustmite? https://dlang.org/blog/2020/04/13/dustmite-the-general-purpose-data-reduction-tool/
Feb 03 2021
parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Wed, Feb 03, 2021 at 03:47:34PM +0000, Imperatorn via Digitalmars-d-learn
wrote:
 On Wednesday, 3 February 2021 at 14:00:23 UTC, JN wrote:
 I am dealing with some nasty issue in my code. Basically random
 unrelated lines of code are crashing with access violations, and if
 I switch from dmd to ldc the crash goes away, or crash comes back,
 or it crashes in a different spot. Seems like I am corrupting some
 memory somewhere (I interact a lot with C libraries). Do you know of
 any tools I could use to try to narrow it down?
[...]
 Or dustmite?
 https://dlang.org/blog/2020/04/13/dustmite-the-general-purpose-data-reduction-tool/
Dustmite generally does not do well with errors that move around and/or occasionally go away when the code changes slightly. It tends to misidentify the problem in such cases and reduce to something that isn't related to the original program. It's more suitable for problems that are 100% reliably reproduced. Pointer bugs / memory corruption often do not fall into that category. T -- It is not the employer who pays the wages. Employers only handle the money. It is the customer who pays the wages. -- Henry Ford
Feb 03 2021
parent Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Wednesday, 3 February 2021 at 15:59:28 UTC, H. S. Teoh wrote:
 On Wed, Feb 03, 2021 at 03:47:34PM +0000, Imperatorn via 
 Digitalmars-d-learn wrote:
 On Wednesday, 3 February 2021 at 14:00:23 UTC, JN wrote:
 [...]
[...]
 Or dustmite? 
 https://dlang.org/blog/2020/04/13/dustmite-the-general-purpose-data-reduction-tool/
Dustmite generally does not do well with errors that move around and/or occasionally go away when the code changes slightly. It tends to misidentify the problem in such cases and reduce to something that isn't related to the original program. It's more suitable for problems that are 100% reliably reproduced. Pointer bugs / memory corruption often do not fall into that category. T
Yes, Valgrind is the way to go
Feb 03 2021
prev sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Wed, Feb 03, 2021 at 02:00:23PM +0000, JN via Digitalmars-d-learn wrote:
 I am dealing with some nasty issue in my code. Basically random
 unrelated lines of code are crashing with access violations, and if I
 switch from dmd to ldc the crash goes away, or crash comes back, or it
 crashes in a different spot. Seems like I am corrupting some memory
 somewhere (I interact a lot with C libraries). Do you know of any
 tools I could use to try to narrow it down?
 
 I've used Application Verifier but so far it didn't point me to
 anything specific.
Valgrind maybe? Most of the tools that work with C/C++ should also work with little or no modifications for D programs. T -- Real men don't take backups. They put their source on a public FTP-server and let the world mirror it. -- Linus Torvalds
Feb 03 2021