Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

munmap_chunk(): invalid pointer #23

Closed
Sukori opened this issue Jul 30, 2024 · 1 comment
Closed

munmap_chunk(): invalid pointer #23

Sukori opened this issue Jul 30, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Sukori
Copy link
Collaborator

Sukori commented Jul 30, 2024

WTF is this ?

echo $_ | wc
munmap_chunk(): invalid pointer
c 0 0 0

expected:
no invalid pointer
wc values for the echo as normal

@Sukori Sukori added the bug Something isn't working label Jul 30, 2024
@Sukori Sukori self-assigned this Jul 30, 2024
@Sukori
Copy link
Collaborator Author

Sukori commented Aug 9, 2024

https://stackoverflow.com/questions/32118545/munmap-chunk-invalid-pointer

In the function second(), the assignment word = "ab"; assigns a new pointer to word, overwriting the pointer obtained through malloc(). When you call free() on the pointer later on, the program crashes because you pass a pointer to free() that has not been obtained through malloc().

Assigning string literals does not have the effect of copying their content as you might have thought. To copy the content of a string literal, use strcpy()

(or strdup in our case ?)

munmap_chunk() is an internal function of the libc's memory management routine. This error message means that by writing into memory that does not belong to an object (but belongs to your process so no segfault), you corrupted internal data structures belonging to these routines. Trying to use these corrupted data structures, the internal routines crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants