malloc error when trying to assign the returned pointer to a struct field
rempas
rempas at tutanota.com
Sat Sep 9 10:01:02 UTC 2023
On Saturday, 9 September 2023 at 09:47:14 UTC, Steven
Schveighoffer wrote:
> You are focusing on the wrong problem.
>
> You asked for size bytes, and malloc gave you size bytes. It
> doesn't "know" anything special.
>
> Then you proceeded at some point to write *past* the size
> bytes. What did you overwrite? Probably some internal malloc
> implementation structure. Then it later noticed "hey, this
> structure doesn't make sense, I'm going to report it to the
> user!" That's why you see the message.
>
> Memory problems are very difficult to find, and typically an
> error is triggered far away from the source, in seemingly
> unrelated code. This is why whenever I see an error that smells
> like memory corruption, I stop all other work and find it.
> Memory errors can come and go based on random chance or how the
> compiler lays out functions. So having it "just go away" isn't
> enough. Very very infrequently, this happens because of a
> codegen issue, but most of the time it's pilot error.
>
> -Steve
I understand! Thank you for the valuable information. I do have
lots of things to learn it seems. But that means that I also
won't get bored anytime soon ;)
More information about the Digitalmars-d-learn
mailing list