I think you are saying that you have a double free: you have an argument that contains deadbeef, indicating that it has been freed.  I don't think you need to write any code.

You need to turn on 0x2 in MEMAUDIT, to engage tstack auditing. Remember that the tstack contains death warrants for blocks that have been allocated.  The double free happens when there is an erroneous free that frees the block while the death warrant is still active; the application of the death warrant is the double free, but the error happened earlier.

tstack auditing goes through the tstack, counting the number of death warrants for each block.  If that number exceeds the usecount of the block, an erroneopus free has occurred and the audit segfaults.  You can add calls to the tstack auditor in your code to narrow down the source of the error.

If you still want to see all allocations, they go through jtgaf() in m.c.

hhr

On 11/13/2023 12:51 AM, Raul Miller wrote:
The problem i'm experiencing is that I'm adding two extended precision
numbers and I get a segfault because one has a corrupted memory
address. I turn on MEMAUDIT=0x1d and I get an ARGCHK failure because
one of the arguments is has low bits set in flags (and is 0xdeadbeef).

So, I have a memory address which was allocated and I need to "go back
in time" to see what's happening with that memory address. (If it
changes in response to my code update, it presumably would only change
once - not when I only change the numeric value that I'm searching
for.)

In other words, I want to create a routine deadcheck() which reports
when it's being called with an address which matches the failing
address, along with a counter. Once I have this information, I can
perform a run where I stop when I reach a certain count of the
appearance of that memory address (or maybe every time, if the total
count is low), and inspect the stack to see what's going on there. I
am hoping that with this information I can zero in on what is being
corrupted, and when.

But, to do this, I need to run deadcheck every time memory gets
allocated / handed to J as a new empty array. (I also put in a
deadcheck in the gmp memory allocator, of course.)

So, ... I'm wondering where I can check all memory allocations.

--
Raul

On Sun, Nov 12, 2023 at 8:40 PM Henry Rich <henryhr...@gmail.com> wrote:
I'm not sure I understand what you want to know.  The tpop stack holds
the death warrants for recently allocated blocks.

hhr

On 11/12/2023 6:56 PM, Raul Miller wrote:
If I want to test all the addresses of "newly allocated pointers to
memory" from m.c, where should I do that?

Thanks,

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to