Excel crashes when calling CallWorksheetFunction from thread-safe XLL UDF

Add-in Express™ Support Service
That's what is more important than anything else

Excel crashes when calling CallWorksheetFunction from thread-safe XLL UDF
 
Jason Rodman




Posts: 33
Joined: 2016-11-01
I have been experiencing sporadic excel crashes when calling an XLL UDF, but only when I copy and paste a large number of the formulas into a spreadsheet (200+). I was able to narrow down the issue to the Module.CallWorksheetFunction(ADXExcelWorksheetFunction.Caller) call that my UDF makes to identify the caller of the function. This function is marked as thread-safe so its running multi-threaded which is supposed to work according to this article I based it on: https://www.add-in-express.com/creating-addins-blog/2011/10/07/thread-safe-xll-caller-address/

Here is the code I am using:


var caller = Module.CallWorksheetFunction(ADXExcelWorksheetFunction.Caller) as ADXExcelRef;
var bookAndSheet = Module.CallWorksheetFunction(xlSheetNm, callerRef).ToString();


If I comment out the second call, I still get a crash. Only when I comment out both calls do the crashes stop happening. And I can only cause the crash 8 out of 10 times when I try this though. Doesn't seem to matter whether I am debugging or not. Currently I am running this in Excel 2013 (15.0.4927.1000) 32bit. I am running your latest release version 8.6.4408.
Posted 22 May, 2017 15:02:02 Top
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
Hello Jason,

Make sure that you use adxloader DLLs version 8.6. If this doesn't help please send us a sample project and steps to follow in order to reproduce the issue.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 23 May, 2017 06:36:14 Top
Jason Rodman




Posts: 33
Joined: 2016-11-01
I have sent you a sample project that reliably reproduces the problem. All you need to do is run it, call the function one time on first line, then copy that formula and then paste it down at least a few hundred lines. It crashes excel once you paste a large enough set of functions at a time. If it doesn't, keep increasing the number of cells to paste until it does. Please let me know that you have received it.
Posted 23 May, 2017 09:50:13 Top
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
Thank you Jason,

I can't reproduce the issue using Excel 2013 15.0.4927.1000 32bit. I paste the formula to a thousand cells at once and I have ten thousand cells pasted with no issue.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 24 May, 2017 05:24:39 Top
Jason Rodman




Posts: 33
Joined: 2016-11-01
This problem is a bit perplexing. I can get it to crash 8/10 times I try it. I thought it might have something to do with memory consumption because I had two instances of VS open and a few other programs like outlook running at the same time. I closed them all down and crashing stopped. I opened them up one at a time to try and get it to crash and it did. I closed them back down and it still crashed with nothing open. Very frustrating. I was pasting anywhere from 2000-10000 cells and causing it to crash. I will test around on other machines to see if its simply isolated to my developer machine. It could be something wrong with my .net install or office patch. I will let you know. See if you can get it to crash by continue to increase the number of cells you paste.
Posted 24 May, 2017 09:32:09 Top
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
Jason,

I've just pasted some 60000 and then 200000 cells with no issue.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 24 May, 2017 09:42:29 Top
Jason Rodman




Posts: 33
Joined: 2016-11-01
I am at a loss with this issue, it appears to be isolated to my machine. Can't repro it on any other machine. Sorry to waste your time with this.
Posted 24 May, 2017 13:03:44 Top
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
Hello Jason,

No problem. Absolutely. Turn off all other COM add-ins and Excel add-ins. Also make sure no VBA macro is involved.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 25 May, 2017 04:54:31 Top