restgeta.blogg.se

Purebasic image memory allocation
Purebasic image memory allocation







purebasic image memory allocation
  1. PUREBASIC IMAGE MEMORY ALLOCATION MANUAL
  2. PUREBASIC IMAGE MEMORY ALLOCATION WINDOWS 10
  3. PUREBASIC IMAGE MEMORY ALLOCATION CODE

If I had anything I needed to cleanup in my threads I would do so but I just want the process to end without having to keep track of them all and signal them to end. I tried to call EndProcess_(0) directly but this results in a debugger error "The debugged executable quit unexpectedly." The same occurs with TerminateProcess_(GetCurrentProcess_(),0). If you are insistent on freeing memory then halting all active threads should be part of this cleanup process to mitigate these kinds of access errors. I could keep track of my threads and perform signaling and suspension myself but this shouldn't be necessary.

purebasic image memory allocation

My initial report was based on the assumption that some kind of behavior is occurring during process termination that is causing this access error and this meticulous memory freeing by PureBasic seems to be the cause. But it is completely unnecessary to free memory allocations and this kind of housekeeping simply delays the process termination. The recommended procedure is to simply ExitProcess() and, if you really want to lock down any existing threads, enumerate through anything that is not the main thread and SuspendThread() instead. KillThread() in this regard is also risky because it's unknown what other threads may exist that rely upon another. The recommendation by Raymond Chen is to simply halt any work that is being done and end the process.

PUREBASIC IMAGE MEMORY ALLOCATION MANUAL

These kinds of memory access errors can occur due to the inherent unpredictability of trying to intentionally perform this kind of manual cleanup during process termination. If this is what PureBasic is doing then I have to disagree with this implementation of process termination. In your case the crash is probably happening because the PB memory heap has already been destroyed when the AllocateMemory() call happens. such conditions are bound to happen because the thread is still accessing resources that the main program is in the process of cleaning up. I don't know what would happen with the debugger off and the error is not consistent enough to test.

PUREBASIC IMAGE MEMORY ALLOCATION WINDOWS 10

I'm using PureBasic 5.73 x86 on Windows 10 圆4 with the thread safety compiler option turned on and the debugger enabled. At a minimum I would expect AllocateMemory() to return 0 instead of trying to access invalid memory.

purebasic image memory allocation

It would be possible to try and signal the thread to end before termination but I don't think this kind of housekeeping should be necessary.

PUREBASIC IMAGE MEMORY ALLOCATION CODE

I'm reporting this as a bug instead of a coding question as I would like for AllocateMemory() or the process termination code to be looked at to see if there is anything obvious for this particular use case that might have been overlooked. I have been unable to reproduce this with a small test but it always appears at the same line in my program. The access error is inconsistent on each run but appears to be a race condition with an allocation which occurs in another thread. I'm experiencing intermittent Invalid memory access errors (read error at a random address) at an AllocateMemory() after a program has reached the end (no End keyboard the program simply reaches the end of the main source file).









Purebasic image memory allocation