Memory Error

When my App work I have a Memory Error.
What is the problem?

Process: ExtractorStudioMac [1385]
Path: /Users/USER/*/ExtractorStudioMac.app/Contents/MacOS/ExtractorStudioMac
Identifier: it.pesarosystem.ExtractorStudio
Version: ??? (2.0.3.0.203)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: ExtractorStudioMac [1385]
User ID: 501

Date/Time: 2017-11-17 11:38:34.651 +0100
OS Version: Mac OS X 10.12.5 (16F73)
Report Version: 12
Anonymous UUID: 8910C8B6-3CF9-0413-8EB9-F363E81AAD11

Time Awake Since Boot: 2200 seconds

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000090
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]

VM Regions Near 0x90:
–>
__TEXT 0000000103eb0000-000000010437c000 [ 4912K] r-x/rwx SM=COW /Users/USER/*/ExtractorStudioMac.app/Contents/MacOS/ExtractorStudioMac

Application Specific Information:
Performing @selector(performClick:) from sender XOJButton 0x600000340630

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.WebCore 0x00007fffd64bf70c WebCore::FrameLoader::numPendingOrLoadingRequests(bool) const + 12
1 com.apple.WebCore 0x00007fffd715a96d WebCore::ProgressTracker::incrementProgress(unsigned long, unsigned int) + 141
2 com.apple.WebCore 0x00007fffd64bf65d WebCore::ResourceLoadNotifier::didReceiveData(WebCore::ResourceLoader*, char const*, int, int) + 61
3 com.apple.WebCore 0x00007fffd72cdd67 WebCore::ResourceLoader::didReceiveDataOrBuffer(char const*, unsigned int, WTF::RefPtrWebCore::SharedBuffer&&, long long, WebCore::DataPayloadType) + 135
4 com.apple.WebCore 0x00007fffd742533f WebCore::SubresourceLoader::didReceiveDataOrBuffer(char const*, int, WTF::RefPtrWebCore::SharedBuffer&&, long long, WebCore::DataPayloadType) + 127
5 com.apple.WebCore 0x00007fffd742543a WebCore::SubresourceLoader::didReceiveBuffer(WTF::RefWebCore::SharedBuffer&&, long long, WebCore::DataPayloadType) + 42
6 com.apple.WebCore 0x00007fffd75bd79a -[WebCoreResourceHandleAsDelegate connection:didReceiveDataArray:] + 106
7 com.apple.CFNetwork 0x00007fffce41f313 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 72
8 com.apple.CFNetwork 0x00007fffce41f225 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 198
9 com.apple.CFNetwork 0x00007fffce41f14d -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 48
10 com.apple.CFNetwork 0x00007fffce42368c _NSURLConnectionDidReceiveDataArray(_CFURLConnection*, __CFArray const*, void const*) + 82
11 com.apple.CFNetwork 0x00007fffce4232bb ___ZN27URLConnectionClient_Classic29_delegate_didReceiveDataArrayEv_block_invoke + 149
12 com.apple.CFNetwork 0x00007fffce5bcb4f ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 100
13 libdispatch.dylib 0x00007fffe4e358fc _dispatch_client_callout + 8
14 libdispatch.dylib 0x00007fffe4e49ccd _dispatch_block_invoke_direct + 322
15 com.apple.CFNetwork 0x00007fffce41f018 RunloopBlockContext::_invoke_block(void const*, void*) + 24
16 com.apple.CoreFoundation 0x00007fffcf281944 CFArrayApplyFunction + 68
17 com.apple.CFNetwork 0x00007fffce41ef11 RunloopBlockContext::perform() + 137
18 com.apple.CFNetwork 0x00007fffce41edaa MultiplexerSource::perform() + 282
19 com.apple.CFNetwork 0x00007fffce41ebcc MultiplexerSource::_perform(void*) + 72
20 com.apple.CoreFoundation 0x00007fffcf2dd3e1 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
21 com.apple.CoreFoundation 0x00007fffcf2be65c __CFRunLoopDoSources0 + 556
22 com.apple.CoreFoundation 0x00007fffcf2bdb46 __CFRunLoopRun + 934
23 com.apple.CoreFoundation 0x00007fffcf2bd544 CFRunLoopRunSpecific + 420
24 com.apple.HIToolbox 0x00007fffce81debc RunCurrentEventLoopInMode + 240
25 com.apple.HIToolbox 0x00007fffce81dcf1 ReceiveNextEventCommon + 432
26 com.apple.HIToolbox 0x00007fffce81db26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
27 com.apple.AppKit 0x00007fffccdb6a54 _DPSNextEvent + 1120
28 com.apple.AppKit 0x00007fffcd5327ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
29 com.xojo.XojoFramework 0x0000000104645a5a 0x104607000 + 256602
30 com.xojo.XojoFramework 0x0000000104644dd4 0x104607000 + 253396
31 com.xojo.XojoFramework 0x00000001047aa54a 0x104607000 + 1717578
32 com.xojo.XojoFramework 0x00000001046c7c6a RuntimeDoEvents + 16
33 it.pesarosystem.ExtractorStudio 0x0000000103f075cc Application.DoEvents%%oi8 + 12
34 it.pesarosystem.ExtractorStudio 0x0000000104275086 fMain.fMain.WebCustomer_DocumentProgressChanged%%o<fMain.fMain>osi8 + 982
35 it.pesarosystem.ExtractorStudio 0x0000000104292765 Delegate.IM_Invoke%%osi8 + 69
36 it.pesarosystem.ExtractorStudio 0x00000001042927fe AddHandler.Stub.31%%si8 + 94
37 it.pesarosystem.ExtractorStudio 0x0000000103f92261 HTMLViewer.Event_DocumentProgressChanged%%osi8 + 97
38 com.apple.CoreFoundation 0x00007fffcf2d354c CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER + 12
39 com.apple.CoreFoundation 0x00007fffcf2d344b _CFXRegistrationPost + 427
40 com.apple.CoreFoundation 0x00007fffcf2d31b2 ___CFXNotificationPost_block_invoke + 50
41 com.apple.CoreFoundation 0x00007fffcf291782 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 2018
42 com.apple.CoreFoundation 0x00007fffcf29076b _CFXNotificationPost + 667
43 com.apple.Foundation 0x00007fffd0cd2907 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
44 com.apple.WebCore 0x00007fffd64b8559 WebCore::ProgressTracker::finalProgressComplete() + 57
45 com.apple.WebCore 0x00007fffd715a6bf WebCore::ProgressTracker::progressCompleted(WebCore::Frame&) + 47
46 com.apple.WebCore 0x00007fffd6482a03 WebCore::FrameLoader::checkLoadCompleteForThisFrame() + 515
47 com.apple.WebCore 0x00007fffd648275b WebCore::FrameLoader::checkLoadComplete() + 443
48 com.apple.WebCore 0x00007fffd65a4c2c WebCore::ResourceLoader::cancel(WebCore::ResourceError const&) + 460
49 com.apple.WebCore 0x00007fffd65a49d4 WebCore::ResourceLoader::cancel() + 68
50 com.apple.WebCore 0x00007fffd64ab5f8 WebCore::DocumentLoader::stopLoadingSubresources() + 296
51 com.apple.WebCore 0x00007fffd649c7e5 WebCore::DocumentLoader::stopLoading() + 2341
52 com.apple.WebCore 0x00007fffd649be03 WebCore::FrameLoader::stopAllLoaders(WebCore::ClearProvisionalItemPolicy) + 227
53 com.apple.WebCore 0x00007fffd666c3af WebCore::FrameLoader::stopForUserCancel(bool) + 31
54 it.pesarosystem.ExtractorStudio 0x0000000103f8d6b2 _HTMLViewerPlugin.Cancel%%o<_HTMLViewerPlugin> + 66
55 it.pesarosystem.ExtractorStudio 0x0000000103f931ec HTMLViewer.Cancel%%o + 60
56 it.pesarosystem.ExtractorStudio 0x0000000104266503 fMain.fMain.cmdAvviaPgIt_Action%%o<fMain.fMain>o + 61747
57 it.pesarosystem.ExtractorStudio 0x0000000104292265 Delegate.IM_Invoke%%o + 53
58 it.pesarosystem.ExtractorStudio 0x00000001042922d4 AddHandler.Stub.15%% + 52
59 libsystem_trace.dylib 0x00007fffe509d3a7 _os_activity_initiate_impl + 53
60 com.apple.AppKit 0x00007fffcd534721 -[NSApplication(NSResponder) sendAction:to:from:] + 456
61 com.apple.AppKit 0x00007fffcd018cc4 -[NSControl sendAction:to:] + 86
62 com.apple.AppKit 0x00007fffcd018bec __26-[NSCell _sendActionFrom:]_block_invoke + 136
63 libsystem_trace.dylib 0x00007fffe509d3a7 _os_activity_initiate_impl + 53

a crash deep in WebKit.
Fill a bug report with Apple or the WebKit project.

Now I sound like Sam: if this is 32bit try 64bit and don’t bother to file a bug report with Apple.

You are using Application.DoEvents. DoEvents is only to be used in console applications.

This is the line:

33 it.pesarosystem.ExtractorStudio	0x0000000103f075cc Application.DoEvents%%o<Application>i8 + 12

I made feature request to raise exception if called in wrong place.
e.g. <https://xojo.com/issue/2519>

@Eli Ott , Yes, I have many App.DoEvents.
What I can use for not block my application?

What are you doing to block your application?

I have a for-next , in this for-next i call a web page in a HTMLViewer and I have to wait the “DocumentComplete” event. After called web page I wait in a loop the global variable is true. When the “DocumentComplete” event run I set a global variable to true. And continue for. I did set App.DoEvent in loop to wait the finish download web page.
The user can STOP the for-next by a button.

How I can to do for wait the complete download page in HTMLViewer and not block the application, so the user can STOP for-next?

Ugh… yeah. That’s what I thought. My code has a similar part for printing/pdf generation

As usual everything needs to be done in a thread. You need some sort of notification management. Or use the observer pattern. That’s the key part because the HtmlViewer needs to signal the rest of the code when it’s finished.

  1. Start the printing:
MainWindow(theWindow).CCPrint1.SetHtml(theHtml)

and

'wait until printing is finished with timeout of 10 minutes dim StartTicks as Integer = Ticks dim EndTicks as Integer = Ticks while (not PrintFinished) and (EndTicks - StartTicks <= 60 * 60 * 10) app.SleepCurrentThread(25) EndTicks = Ticks wend

  1. In the print container this starts a timer to load the html. Otherwise crashes occur:
HtmlTimer.Mode = Timer.ModeSingle
  1. In DocumentComplete the printing is done and the notification is sent:

dim tempItem as FolderItem = getTempFolderitem call HTMLViewer1.PrintToPDFFileMBS(tempItem, 50, 50, 50, 50) NotificationManager.Post "PDFCreated", TempItem.NativePath

  1. The notification back in the main print code does the rest.

thePDFFile = getFolderItem(UserData, FolderItem.PathTypeNative) PrintFinished = True

so that the original loop is finished.

And pretty please don’t use global variable for this.

@Beatrix Willius thanks, I’ll try to do it.

Sorry @Beatrix Willius , you have all in the same Window?

Here you go Gabriele, a simple example I just put together for you:

https://www.dropbox.com/s/tqmkkzvn3zrwkkr/SimpleHTMLStateMachine.xojo_binary_project?dl=1

No for loops or doevents in sight :wink:

There are a few ways to do this, while this might not be the best or the neatest, its just an example :slight_smile:

I’ve had a similar thing. Every time when I’ve pressed the close button I get

[code]Time Awake Since Boot: 20000 seconds
Time Since Wake: 2600 seconds

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000001fc
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]

VM Regions Near 0x1fc:
–>
__TEXT 0000000000001000-0000000000333000 [ 3272K] r-x/rwx SM=COW [/code]

My work around is a

CLEARFOCUS

into the beginning of event handler for the event close.

If you used App.DoEvents it might be the same reason for this error, if you do not used App.DoEvents it is something completely different. By the way, the interesting part is the call stack of the thread which crashed, not the part you have posted.

Sorry but I did not understand something …
I read the code of an HTML page. I have a for-next for all the links I’ve found. For each link I load in an HTML Viewer the web page. The for-next does not have to go as long as the current link page is not fully loaded, and the application is not blocked because the user must be able to stop the search on the “Stop” button.

In my example;

Put the For Next loop in DocumentComplete (inside the IF) parse and add the links to an array of strings (window property).

In DoIncrement, remove each of the strings off the array and send them to Browse.

This will get all the links recursively.

If you dont want recursive, just put a window property in that says its the initial download of a page (and remember to reset it when you have removed all strings from the array)