Worker problem

Hi, I’ve created a worker that runs fine for debug builds but fails with an error event being fired when built as a MacOS Desktop app. The app creates various files in specialfolder.temporary and passes the nativepath to the Worker so it can access the contents of this file and do what it needs to do… any thoughts as the error event only contains the jobdata sent to it and I’m unable to debug it as it works for a debug run. Many thanks, Dave.

Be sure you are catching possible exceptions.

You might also try using System.DebugLog to help you determine why it is failing.

Thanks Paul, I’m quite literally throwing in a load of debug lines here and there right now…

Just seems odd that it runs in debug but not built.

Remember that in debug mode, it runs as a Thread, not an external application.

1 Like

I’m using MBS Plug In Set, I wonder if I have to put Christians activation code in there - but there’s no open event…

Yes, you would need to activate plugins. Remember, these Worker Helpers are separate console apps. They do not retain any state from your main app. You could add a method to the Worker class to activate the plugins and then call it at the beginning of JobRun.

Perfect!

Sadly still not working, noticed there’s a Crash Report:

Process: outstandingInvoicesWorker [49065]
Path: /Users/USER/Documents/*/Order System v5.app/Contents/Helpers/Workers/outstandingInvoicesWorker
Identifier: outstandingInvoicesWorker
Version: 0
Code Type: X86-64 (Native)
Parent Process: Order System v5 [49046]
Responsible: Order System v5 [49046]
User ID: 501

Date/Time: 2020-12-15 14:18:08.402 +0000
OS Version: macOS 11.0.1 (20B50)
Report Version: 12
Anonymous UUID: BD46F3E1-EB95-06FB-836E-A346560EAD7C

Sleep/Wake UUID: 801D42C1-3782-43AB-B25C-E688BA0CB444

Time Awake Since Boot: 440000 seconds
Time Since Wake: 3500 seconds

System Integrity Protection: enabled

Crashed Thread: 2

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

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

VM Regions Near 0x30:
–>
__TEXT 10dc50000-10dd35000 [ 916K] r-x/rwx SM=COW /Users//Documents//Order System v5.app/Contents/Helpers/Workers/outstandingInvoicesWorker

Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff202eb8e2 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff2031de6f _pthread_cond_wait + 1254
2 rbframework.dylib 0x000000010df7fb08 xojo::ConditionVariable::Wait(xojo::UniqueLock&) + 12
3 rbframework.dylib 0x000000010df8abd4 0x10ddbe000 + 1887188

Is there a maximum string length you can send to a Worker?

Put your build in /Applications and try from there?

Done, same outcome :frowning:

Checked the permissions on the files the app creates (owned by me) and the worker process is running as me so there shouldn’t be any file access permissions issues. Very odd this.

do you read any files in the documents folder?

Post the part of the crash log where is says “Thread 2”. That will be the interesting part.

I tested the other day and it loses reliability here after about 100k.

Thread 2 Crashed:
0 rbframework.dylib 0x000000010aa0d609 REALdbCursorFromDBCursor(dbCursor*, REALdbCursorDefinition*) + 41
1 MBS_SQL_RecordClone_Plugin_20393.dylib 0x000000010af443ab BuildRecordSetMBS(_REALarrayString*, _REALarrayString*) + 1275
2 outstandingInvoicesWorker 0x000000010a6d6356 RecordCloneGlobalsMBS.BuildRecordSetMBS%o%A1sA1s + 70
3 outstandingInvoicesWorker 0x000000010a6dd3cc outstandingInvoicesWorker.JSONToRecords%o%os + 4140
4 outstandingInvoicesWorker 0x000000010a6d9d3f outstandingInvoicesWorker.Event_JobRun%s%os + 4159
5 outstandingInvoicesWorker 0x000000010a691441 Worker._RaiseJobRun%s%os + 129
6 outstandingInvoicesWorker 0x000000010a69ad8a _WorkerThread.Event_Run%%o<_WorkerThread> + 266
7 rbframework.dylib 0x000000010a944e8d 0x10a779000 + 1883789
8 rbframework.dylib 0x000000010a93a8c7 0x10a779000 + 1841351
9 libsystem_pthread.dylib 0x00007fff2031d950 _pthread_start + 224
10 libsystem_pthread.dylib 0x00007fff2031947b thread_start + 15

No DerkJ, the files are generated into specialfolder.temorary…

1 Like

How do you handle the access to the MBS plugin? To avoid crashes to need to open the database, do whatever you need to do and then close the database.

Do you think that might be the problem as the worker doesn’t create or connect to a database… can you create a recordset without a database connection?