Invalid memory access on EndProcedure
Invalid memory access on EndProcedure
Quite often my program crashes with "Invalid memory access" on EndProcedure for no apparent reason. It's never consistent and doesn't always happen on the same EndProcedure. It only happens on macOS. Does anyone have any idea how I can track this down and solve it?
Re: Invalid memory access on EndProcedure
Sounds like a stack corruption or memory overflow.
Do you use any user includes or third party libraries?
Have you tried to enable the Purifier in the debugger tools?
Do you use threads without enabled thread safe mode?
Do you use any user includes or third party libraries?
Have you tried to enable the Purifier in the debugger tools?
Do you use threads without enabled thread safe mode?
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: Invalid memory access on EndProcedure
I do use your TabBarGadget and the GoScintilla includes. Quite often the IMA happens in the TabBarGadget code, but I'm not placing the blame on that because the PureBasic IDE uses it and that never crashes randomly. If it happens in that include, it's usually at the end of the callback procedure.
I have tried the Purifier, but I am lost on what it actually does. Does it notify you?
I have thread-safe mode enabled.
I have tried the Purifier, but I am lost on what it actually does. Does it notify you?
I have thread-safe mode enabled.
Re: Invalid memory access on EndProcedure
The TabBarGadget_Callback() procedure is bind to the canvas gadget of this custom gadget.
If it crashes there, it could be an error in the window event management.
Do you actually use threads? (CreateThread)
If it crashes there, it could be an error in the window event management.
Do you actually use threads? (CreateThread)
The Purifier creates a magic number behind an allocated memory or string to detect an overwrite of this area. The Purifier can prevent randomly crashes, when a routine would corrupt the memory heap zone for example.wombats wrote: Wed Aug 23, 2023 4:55 am I have tried the Purifier, but I am lost on what it actually does. Does it notify you?
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: Invalid memory access on EndProcedure
Thank you.
I only use CreateThread once and not for anything major.
Does the Purifier alert you of problems? I've never seen it do anything, so I'm confused on how it functions. Do we have to look at the magic numbers?
The IMA is always on the actual "EndProcedure" line. I'll try the Purifier again and try to check my window management.
I only use CreateThread once and not for anything major.
Does the Purifier alert you of problems? I've never seen it do anything, so I'm confused on how it functions. Do we have to look at the magic numbers?
The IMA is always on the actual "EndProcedure" line. I'll try the Purifier again and try to check my window management.
Re: Invalid memory access on EndProcedure
In the thread, do you use changes from Gadgets or Windows. This does not work in macOS and Linux threads. You have to pass them on to the MainScope with PostEvent.
If you use CocoaMessage in the thread, you must create your own pool, otherwise it will be destroyed by the MainScope.
If you use CocoaMessage in the thread, you must create your own pool, otherwise it will be destroyed by the MainScope.
Code: Select all
Procedure MyThread(*Exit.Integer)
Protected Pool
Repeat
Pool = CocoaMessage(0, 0, "NSAutoreleasePool new")
;TODO
If Pool
CocoaMessage(0, Pool, "release")
EndIf
Delay(100)
Until *Exit\i
EndProcedure
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Invalid memory access on EndProcedure
WHAT???mk-soft wrote: Thu Aug 24, 2023 5:38 pmIf you use CocoaMessage in the thread, you must create your own pool, otherwise it will be destroyed by the MainScope.




Re: Invalid memory access on EndProcedure
Are you use Window, Gadgets or Menu functions within this thread?wombats wrote: Thu Aug 24, 2023 4:48 pm Thank you.
I only use CreateThread once and not for anything major.
Does the Purifier alert you of problems? I've never seen it do anything, so I'm confused on how it functions. Do we have to look at the magic numbers?
The IMA is always on the actual "EndProcedure" line. I'll try the Purifier again and try to check my window management.
Here is an example for the Purifier:
Code: Select all
PurifierGranularity(1,1,1,1)
Define *Buffer = AllocateMemory(10) ; Alloclate a too small memory
ShowMemoryViewer(*Buffer, 20)
PokeS(*Buffer, "Hello World!", -1, #PB_Ascii) ; Write over the allocated length, gives an error with enabled Purifier
Debug "No error without Purifier"
The Purifier checks every line, if this magic number has been corrupted.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: Invalid memory access on EndProcedure
Thank you, STARGÅTE! I'm glad to see what the Purifier does now. I'll keep it turned on to hopefully catch the problem the next time.
Thanks for the tip about CocoaMessage, mk-soft! I don't use CocoaMessage, Window, Gadgets or Menu functions in the thread. I use PostEvent to do anything I need to.
Thanks for the tip about CocoaMessage, mk-soft! I don't use CocoaMessage, Window, Gadgets or Menu functions in the thread. I use PostEvent to do anything I need to.