« first day (4030 days earlier)      last day (959 days later) » 

12:08 AM
Open letter to students with homework problems and How to ask homework questions: Make a genuine attempt yourself, show the code, ask a specific question. — kaylum 10 secs ago
 
 
3 hours later…
3:34 AM
Hi
I have a query regarding heap metadata
I want to get the address of forward pointer and backward pointer stored , how to print it using gdb
 
4:19 AM
"Is it possible to ____?" is generally considered too broad to be a good question for Stack Overflow—the answer is usually: "yes, it's probably possible, but describing how to do it would entail designing a large piece of software." Instead, you should try to build it, and ask a question when you encounter a specific problem. Please see Why is “Is it possible to…” a poorly worded question? for more information. — Ryan M 33 secs ago
 
 
2 hours later…
6:29 AM
Stack Overflow is a question and answer site for professional and enthusiast programmers. There are other sites in the SE network better suited for this kind of questions. — James Brown 11 secs ago
 
6:53 AM
Nobody is going to just do all the work for you. Open letter to students with homework problems and How to ask homework questions: Make a genuine attempt yourself, show the code, ask a specific question. — kaylum 30 secs ago
 
 
1 hour later…
7:55 AM
@user143252 the allocator re-interprets the contents of the chunk to contain those pointers – GDB doesn't know directly about this. Instead, you'll have to calculate offsets manually, or dump the contents of a freed pointer like with x/2w the_pointer (dump two words in hex-notation). In glibc, first word is forward pointer, second word is backwards pointer (might be unused). And the word before the pointer would contain the size field.
If you have a struct that describes the chunk layout, you could also cast to that struct. E.g. struct chunk { size_t fd, bk; }; then p *(struct chunk*) the_pointer
 
@amon in most of malloc metadata document it shows that forward pointer backward pointer is next to playload, but when I see the hex of malloc address-8, it contain only size information , no where forward pointer or backward pointer. So my question is where Exactly is these address resides in memory if not next to payload
 
So I actually wrote a paper about glibc malloc metadata, and created this diagram to explain where the chunk header fields are:
the size field is just before the address of the chunk
but the fd/bk fields re-use the space where there would usually be user data
these fd/bk fields only exist for chunks that are freed and are stored in one of the allocator bins
the details also depend on the exact version of the allocator. The above diagram matches all ptmalloc2/glibc allocators, but there are significant differences between versions regarding when which field is active
other allocators (like BSD, Windows, tcmalloc) work differently
 
8:13 AM
That means if I just allocated a memory then it should NOT have p->fd and p->bk field my environment is linux glibc-2. 27
@amon can you share your document on heap
 
correct! These fields do not exist for in-use chunks, only for freed chunks. So to observe them, you'd have to do a use-after-free: free(p); forward_pointer = *(size_t**)p;
The paper is called Shadow-Heap and can be downloaded from here: lukasatkinson.de/research
 
This is my scenario, here I am printing metadata from malloc allocation but I am getting fd ptr and bk ptr, moreover both pointer are SAME strange!
That means some nasty peice of code is freeing it
THANKS A LOT, I hope this solves my problem
 
no, I think you're asking that heap addon to your debugger to interpret the chunk as if it were freed, and it's mis-interpreting data from the actual struct. The metadata in the chunk doesn't directly explain whether the chunk is free or in use (you'd have to look at the prev-in-use flag of the next chunk
 
8:32 AM
For the chunk I am asking status is [flag =PREVIN_USE ] but I am not sure how to go to next chunk, do u know any command or you have idea?
I think COMMAND heap chunks may help me
 
 
1 hour later…
9:47 AM
This question is more suited to softwareengineering.stackoverflow.com. — torek 5 secs ago
This might be better for softwareengineering.stackexchange.com rather than Stack Overflow. — mikemaccana 34 secs ago
 
 
6 hours later…
 
5 hours later…
8:07 PM
Welcome to Stack Overflow. Please take the tour to learn how Stack Overflow works and read How to Ask on how to improve the quality of your question. Then check the help center to see what questions you can ask. Please see: Why is “Is it possible to…” a poorly worded question? (don't just change your question to "How"). Please show your attempts you have tried and the problems/error messages you get from your attempts. — Progman 35 secs ago
 
 
3 hours later…

« first day (4030 days earlier)      last day (959 days later) »