OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
690 stars 95 forks source link

Excel Crashes consistently if custom functions add-in use window.localStorage in shared runtime on Windows platforms #1568

Open cghaddar opened 3 years ago

cghaddar commented 3 years ago

Using window.localStorage in a custom function in shared runtime seems to work as long as you have a single instance of Excel and one workbook open. If you open a second workbook in new instance of Excel, it will crash immediately and log the following error to the event log:

Faulting application name: EXCEL.EXE, version: 16.0.13426.20404, time stamp: 0x5fdea626 Faulting module name: mso20win32client.dll, version: 0.0.0.0, time stamp: 0x5fd1d17d Exception code: 0x0152139a Fault offset: 0x0000000000297bfd Faulting process id: 0x46c Faulting application start time: 0x01d6deb16973c7c1 Faulting application path: C:\Program Files\Microsoft Office\Root\Office16\EXCEL.EXE Faulting module path: C:\Program Files\Common Files\Microsoft Shared\Office16\mso20win32client.dll Report Id: c1e58204-54ab-4fc5-9e82-2f2ccf998d94 Faulting package full name: Faulting package-relative application ID:

The stored content in localStorage are also deleted after the crash I have created a simple test below which produces the bug consistently

Expected Behavior

Excel should not crash when multiple instances are opened. It should not delete any stored items in localStorage after crash.

Current Behavior

Please see description above. This bug only happens on Windows Platform. It does not happen on Mac or online.

Steps to Reproduce, or Live Example

I have attached a working project with one simple custom function which uses localStorage. Also attched are two simple workbooks wrkbk1.xlsx and wrkbk2.xlsx. 1) unzip the project 2) do npm install to get all required node modules then build it in Visual Code 3) sideload the add-in by running from Visual Code Terminal -> Run Task -> Debug:Desktop 4) After Excel starts, open wrkbk1.xlsx 5) next open the second wrkbk2.xlsx Excel will crash. Check your event log for the exception shown above.

Context

This is serious embarrassing bug which prevents users from opening multiple workbooks at once when add-in installed.

Your Environment

Useful logs

from Event log Faulting application name: EXCEL.EXE, version: 16.0.13426.20404, time stamp: 0x5fdea626 Faulting module name: mso20win32client.dll, version: 0.0.0.0, time stamp: 0x5fd1d17d Exception code: 0x0152139a Fault offset: 0x0000000000297bfd Faulting process id: 0x46c Faulting application start time: 0x01d6deb16973c7c1 Faulting application path: C:\Program Files\Microsoft Office\Root\Office16\EXCEL.EXE Faulting module path: C:\Program Files\Common Files\Microsoft Shared\Office16\mso20win32client.dll Report Id: c1e58204-54ab-4fc5-9e82-2f2ccf998d94 Faulting package full name: Faulting package-relative application ID: SharedRuntimeCustomFunctionsTest.zip wrkbk1.xlsx wrkbk2.xlsx wrkbk3.xlsx

lindalu-MSFT commented 3 years ago

Phoebe and/or Jeremy, Ruoying is still out on maternity leave. Can you help triage this issue? Thanks, lindalu

@grangeryy @jeremy-msft

jeremy-msft commented 3 years ago

Hi @cghaddar, thanks for reporting. We're currently investigating this issue and will update once we have more info.

jeremy-msft commented 3 years ago

Hi @cghaddar, we have been unable to reproduce this issue. If you are still seeing this problem, could you please share your logs with us after you experience the crash? You can do this with the following steps:

  1. Relaunch Excel and go to File > Feedback
  2. Select "Send a Frown"
  3. Check "Attach my logs to help troubleshoot" and note "SharedRuntime LocalStorage Crash" in the comment field.
cghaddar commented 3 years ago

Hi Jeremy I sent the feed back as requested. I am also attaching a video recording of the crash. Not sure if this is related but I am running Windows 10 in a dedicated hard drive partition on a MacBook Pro laptop rather than a regular PC. Another fact is it seems so far impossible to get any logs when running in shared runtime from custom functions. I have another open report on this (see https://github.com/OfficeDev/office-js/issues/1396#issuecomment-759323988). bug-demo.zip

jeremy-msft commented 3 years ago

Thanks @cghaddar, could you please try applying the attached registry key (rename to .reg) and let us know if that resolves your issue? It will disable a recent change that we think might be causing the problem.

overrideKey.txt

cghaddar commented 3 years ago

Unfortunately, this did not resolve the problem. I verified the reg keys were added, cleared my office cache and restarted Excel multiple times but the problem persists. It sounds like a potential memory access violation. After the crash, the Window.local storage is wiped out the next time I start Excel. Local storage persists if I just start and close and restart one instance of Excel. I did apply all patches to my Windows 10 and Office installation.

madhavagrawal17 commented 3 years ago

Thanks, @cghaddar for validating our suspicion. I tried your scenario locally but I am not able to repro it. We need more info from you.

  1. Does this happen only for custom functions with Localstorage? If Yes, Could you try the same scenario with a simple custom function like '=CONTOSO.ADD'. We would like to check it is a document open problem or a custom functions execution problem.
  2. Could you try using officeruntime.storage instead of Local storage? Officeruntime.storage is same as localstorage here is the doc: https://docs.microsoft.com/en-us/javascript/api/office-runtime/officeruntime.storage?view=excel-js-preview
cghaddar commented 3 years ago

Actually, this could very well be a document loading problem rather than a local storage issue. Here is what observed with more testing:

  1. I get the same crash whether I use the async officeruntime storage or the sync window storage.
  2. Excel does not crash if I open multiple blank books at once. I can evaluate custom functions in any of the open books and Excel is happy.
  3. I opened multiple blank books, saved on with just =CONTOSO.ADD(1,2) formula. Closed the book, then tried to open it again in the same session. Excel crashed again.
  4. After the crash, Excel will try to launch it self again with all the crashed books, and often it succeeds and the opened books are usable. Except that local storage keys are deleted after the recovery.
  5. Without the JS add-in, Excel is normal, I can open as many books as I like with no issues.
    The problem appears indeed related to opening multiple documents with the a JS add-in loaded. I suspect it is related to the shared runtime but I can't confirm because I have not tested an add-in with just office runtime or custom functions runtime.
madhavagrawal17 commented 3 years ago

@cghaddar, Yes! that was my suspicion as well that this crash is happening on document open when it contains custom functions. We fixed a similar issue on the December release. I think the December release is available now. Could you try if this scenario works for you on the December release (16.0.13721.20008)? Also, I would appreciate it if you could follow the below steps to capture the dump file share it with us so that we can investigate the crash more. 1) Download the ProcDump to capture the dump from here: https://docs.microsoft.com/en-us/sysinternals/downloads/procdump 2) Start Excel. 3) Extract ProcDump and on cmd as admin, Run: procdump.exe -e excel.exe 4) Perform your scenario on Excel. 5) Once Excel crashes it will be captured by ProcDump. 6) On the cmd, you can find the path to the .dmp file. 7) Please share the .dmp file along with the version of Excel installed on your machine.

cghaddar commented 3 years ago

@madhavagrawal17, I updated Excel to 16.13628.20234. Excel now says I am up to date, so I m not sure if 16.0.13721.20008 is an available option at this time. I got the attached dmp file with ProcDump EXCEL.EXE_210128_163737.zip Here is console log from ProcDump

ProcDump v10.0 - Sysinternals process dump utility Copyright (C) 2009-2020 Mark Russinovich and Andrew Richards Sysinternals - www.sysinternals.com

Process: EXCEL.EXE (11076) Process image: C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE CPU threshold: n/a Performance counter: n/a Commit threshold: n/a Threshold seconds: n/a Hung window check: Disabled Log debug strings: Disabled Exception monitor: Unhandled Exception filter: [Includes] * [Excludes] Terminate monitor: Disabled Cloning type: Disabled Concurrent limit: n/a Avoid outage: n/a Number of dumps: 1 Dump folder: C:\Users{userid}\Downloads\Procdump\ Dump filename/mask: PROCESSNAME_YYMMDD_HHMMSS Queue to WER: Disabled Kill after dump: Disabled

Press Ctrl-C to end monitoring without terminating the process.

[16:37:37] Exception: C0000005.ACCESS_VIOLATION [16:37:37] Exception: C0000005.ACCESS_VIOLATION [16:37:37] Unhandled: 0152139A [16:37:37] Dump 1 initiated: C:\Users{userid}\Downloads\Procdump\EXCEL.EXE_210128_163737.dmp [16:37:37] Dump 1 complete: 15 MB written in 0.4 seconds [16:37:38] Dump count reached.

madhavagrawal17 commented 3 years ago

@cghaddar, Thank you for sharing the dump. I think now we have all the info needed to investigate this issue. We will update you on the solution. I think you have the December release with 16.13628.20234. It seems 16.0.13721.* is for January release. Sorry for the confusion.

cghaddar commented 3 years ago

@madhavagrawal17 I updated to latest available release 16.0.13628.20318 and the same bug persists.

madhavagrawal17 commented 3 years ago

@cghaddar, Our Custom Functions team is still working on this issue as we are not able to reproduce it locally. I will update you once they have a fix available. Thank you.

madhavagrawal17 commented 3 years ago

@cghaddar, The crash has been fixed and the fix will be available on March's monthly release. Adding @xiaochunms for further tracking.

cghaddar commented 3 years ago

@madhavagrawal17, @xiaochunms, I updated to Version 2102 Build 13801.20360 (latest but not sure if this the intended March's release) but unfortunately the crash continues to happen. I captured the core dump again in case it helps. If this is not the correct build, please post the build number which will contain the fix.

build EXCEL.EXE_210319_101154.zip

Here is the log from ProcDump Process: EXCEL.EXE (24104) Process image: C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE CPU threshold: n/a Performance counter: n/a Commit threshold: n/a Threshold seconds: n/a Hung window check: Disabled Log debug strings: Disabled Exception monitor: Unhandled Exception filter: [Includes] * [Excludes] Terminate monitor: Disabled Cloning type: Disabled Concurrent limit: n/a Avoid outage: n/a Number of dumps: 1 Dump folder: C:\Users{username}\Downloads\Procdump\ Dump filename/mask: PROCESSNAME_YYMMDD_HHMMSS Queue to WER: Disabled Kill after dump: Disabled

Press Ctrl-C to end monitoring without terminating the process.

[10:11:21] Exception: 000006BA [10:11:21] Exception: E06D7363.?AVOException@@ [10:11:21] Exception: E06D7363.?AVOException@@ [10:11:21] Exception: E06D7363.?AVOException@@ [10:11:21] Exception: 40080201 [10:11:22] Exception: E06D7363.?AVOException@@ [10:11:22] Exception: E06D7363.?AVOException@@ [10:11:40] Exception: 80010108 [10:11:54] Exception: C0000005.ACCESS_VIOLATION [10:11:54] Exception: C0000005.ACCESS_VIOLATION [10:11:54] Exception: C0000005.ACCESS_VIOLATION [10:11:54] Exception: C0000005.ACCESS_VIOLATION [10:11:54] Exception: C0000005.ACCESS_VIOLATION [10:11:54] Exception: C0000005.ACCESS_VIOLATION [10:11:54] Exception: C0000005.ACCESS_VIOLATION [10:11:54] Exception: C0000005.ACCESS_VIOLATION [10:11:54] Unhandled: 0152139A [10:11:54] Dump 1 initiated: C:\Users{username}\Downloads\Procdump\EXCEL.EXE_210319_101154.dmp [10:11:56] Dump 1 complete: 16 MB written in 1.3 seconds [10:11:56] Dump count reached.

omardoma commented 2 years ago

We are facing the same issue on Excel for Windows (Edge WebView2). We have an Excel Add-in that utilizes a shared runtime between a Task Pane and Custom Functions. The problem occurs when you attempt to open a workbook that has a custom function written in a cell in any sheet, while you have another workbook already open. So the moment you open the 2nd workbook (with the custom function saved in it), Excel crashes and both are terminated.

How to reproduce:

  1. Create a new blank excel file (File 1)
  2. Write in a cell: =NAMESPACE.FUNCTION(X)
  3. Save the file locally on your pc and close Excel
  4. Create a new blank excel file (File 2)
  5. Write any text in a cell
  6. Open the file with the custom function saved (File 1)
  7. Excel crashes

Version Information:

Version 2102 (Build 13801.21092 Click-to-Run) Semi-Annual Enterprise Channel Edge WebView2 installed

km594 commented 1 year ago

Disclaimer: Unsure if this is the right location to post this. Feel free to point me in a better direction. I only wish to spare the heartache I had with a roughly similar issue (crash just after opening).

Background: I am developing a Ribbon using the customUI OOXML + RibbonX method, for reasons. Excel began crashing when beginning to work with callbacks to IRibbonControl. I am using the following build:

Build: Microsoft® Excel® for Microsoft 365 MSO (Version 2310 Build 16.0.16924.20054) 64-bit Windows

Issue: Excel crashes after loading in for roughly 1-2 seconds. I could see the custom tabs on the Ribbon (indicating that XML had loaded correctly), however I could not inspect further.

Cause: I followed the steps above and found that the process common to crashes was OfficeScripts MRUHelper. I have the OfficeScripts Command in the QAT, again for reasons. I removed the OfficeScripts Command from the QAT and attempted to reproduce the issue. It was fixed. I then made modifications to the XML and reloaded it to be sure.

Notes: