CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2010

    Unhappy Problem with pthreads and memory management

    Hello ! I'm new there, long time lurker though.

    I started a week ago to code a Mandelbrot / Buddhabrot renderer (I have poor C++ skills). Then, I decided this week-end to make my program running on multiple CPU cores. I managed to get the code done, but it crashes randomly, and more frequently the more you add simultaneous threads.

    gdb on mac has this recurrent error when the code decides to crash :
    *** set a breakpoint in malloc_error_break to debug
    test(3964,0xb0103000) malloc: *** error for object 0x102ae00: pointer being freed was not allocated

    (I code on windows, though)

    It seems I lack a correct memory management, but I have absolutely no idea where (tried a few things). You can edit the number of threads running at line 197. My hunch is that the problem lies with the "new" i do at line 200. I need this pointer in order to pass it as an argument to the method called by the thread, so that the method can write its part of the image directly from the thread.

    If somebody could help me, it would be great =) My head is kinda exploding right now =\

    Thanks in advance !

    (feel free to ask any questions regarding the code.)
    Attached Files Attached Files

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Seattle, WA

    Re: Problem with pthreads and memory management

    Your problem is most likely due to insufficient synchronization when multiple threads access (or worse, simultaneously modify) the same data.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.