Deleting pointer sometimes results in heap corruption

前端 未结 7 678
深忆病人
深忆病人 2021-01-07 03:34

I have a multithreaded application that runs using a custom thread pool class. The threads all execute the same function, with different parameters.

These parameters

7条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-07 04:12

    If you try to delete an object twice, the second time will fail, because the heap is already freed. This is the normal behavior.

    Now, since you are in a multithreading context... it might be that the deletions are done "almost" in parallel, which might avoid the error on the second deletion, because the first one is not yet finalized.

提交回复
热议问题