Skip to content

Illegal Instruction (Core Dump) #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
internalkernel opened this issue Feb 19, 2019 · 28 comments
Closed

Illegal Instruction (Core Dump) #110

internalkernel opened this issue Feb 19, 2019 · 28 comments

Comments

@internalkernel
Copy link

internalkernel commented Feb 19, 2019

Hi and thanks for a great app... I recently switched to email-securely from protonmail-desktop but I'm having problems running the app.

It continuously crashes with an Illegal Instruction and Core Dump. I've increased logging but there doesn't seem to be anything useful in there. The only error I see, is if I launch securely from a terrminal - the Illegal Instruction occurs on the command line but there's no evidence of errors in the actual log. In fact the log file isn't created unless I set output to info. I'm running Ubuntu 18.10 & KDE 5.15.

Command Line output:
`
<--- Last few GCs --->

[10038:0x21d53cdbd000] 189186 ms: Mark-sweep 1088.5 (1533.4) -> 1088.5 (1481.4) MB, 26.0 / 0.0 ms (average mu = 0.975, current mu = 0.001) last resort GC in old space requested
[10038:0x21d53cdbd000] 189212 ms: Mark-sweep 1088.5 (1481.4) -> 1088.5 (1459.9) MB, 26.6 / 0.0 ms (average mu = 0.948, current mu = 0.001) last resort GC in old space requested

<--- JS stacktrace --->

==== JS stack trace =========================================

0: ExitFrame [pc: 0x55685777ab2e]

Security context: 0x0aa1b4aa29d9
1: fromString(aka fromString) [0x284e8e39ec39] [buffer.js:341] [bytecode=0x3001a242361 offset=53](this=0x12445d2026f1 ,0x15a0e7e8b711 <Very long string[340707643]>,0x0aa1b4aca891 <String[4]: utf8>)
2: from [0x1d53f4b15f31] [buffer.js:202] [bytecode=0x3001a241f61 offset=11](this=0x151bc08043f1 <JSFunction Buffer (sfi = 0x1d53f4b0c639)>,0x15...

Illegal instruction (core dumped)
`

Log File Output:
[2019-02-19 09:03:51.586] [debug] [WEBVIEW:protonmail] [lib/api] resolveService() queueing rate limited method: "Contact.get" [2019-02-19 09:03:51.586] [verbose] [WEBVIEW:protonmail] [lib/api] resolveService() calling rate limited method: Contact.get {"waitTime":0,"rateLimitedMethodsCallCount":348} [2019-02-19 09:03:51.955] [debug] [WEBVIEW:protonmail] [lib/api] resolveService() queueing rate limited method: "Contact.get" [2019-02-19 09:03:51.955] [verbose] [WEBVIEW:protonmail] [lib/api] resolveService() calling rate limited method: Contact.get {"waitTime":0,"rateLimitedMethodsCallCount":349} [2019-02-19 09:03:52.452] [debug] [WEBVIEW:protonmail] [lib/api] resolveService() queueing rate limited method: "Contact.get" [2019-02-19 09:03:52.453] [verbose] [WEBVIEW:protonmail] [lib/api] resolveService() calling rate limited method: Contact.get {"waitTime":0,"rateLimitedMethodsCallCount":350} [2019-02-19 09:03:52.849] [info] [WEBVIEW:protonmail] [api/build-db-patch] api:buildDbPatch() <[account.component][0]> bootstrapDbPatch() fetched 349 contacts [2019-02-19 09:03:52.849] [verbose] [WEBVIEW:protonmail] [api/build-db-patch] api:buildDbPatch() <[account.component][0]> bootstrapDbPatch() start fetching folders [2019-02-19 09:03:52.849] [debug] [WEBVIEW:protonmail] [lib/api] resolveService() queueing rate limited method: "Label.query" [2019-02-19 09:03:52.849] [verbose] [WEBVIEW:protonmail] [lib/api] resolveService() calling rate limited method: Label.query {"waitTime":0,"rateLimitedMethodsCallCount":351} [2019-02-19 09:03:53.236] [info] [WEBVIEW:protonmail] [api/build-db-patch] api:buildDbPatch() <[account.component][0]> bootstrapDbPatch() fetched 54 folders [2019-02-19 09:03:53.237] [verbose] [WEBVIEW:protonmail] [api/build-db-patch] api:buildDbPatch() <[account.component][0]> bootstrapDbPatch() construct initial database patch [2019-02-19 09:03:53.245] [verbose] [WEBVIEW:protonmail] [api/build-db-patch] api:buildDbPatch() <[account.component][0]> bootstrapDbPatch() trigger initial storing [2019-02-19 09:03:53.245] [info] [WEBVIEW:protonmail] [api/build-db-patch] api:buildDbPatch() <[account.component][0]> persist() start [2019-02-19 09:03:53.257] [info] [electron-main/api/endpoints-builders/database] dbPatch() [2019-02-19 09:03:53.382] [info] [electron-main/api/endpoints-builders/database] patchMetadata() [2019-02-19 09:03:53.382] [verbose] [electron-main/api/endpoints-builders/database] dbPatch() {"entitiesModified":true,"metadataModified":false,"modified":true} [2019-02-19 09:03:53.382] [info] [electron-main/database] saveToFile() [2019-02-19 09:03:53.383] [verbose] [preload: database-indexer] [index] dbIndexerNotification.next, action.type: ipc_main_api_db_indexer_notification_actions:Index [2019-02-19 09:03:53.383] [info] [preload: database-indexer] [index] action.Index() Received mails to remove/add: 0/0 [2019-02-19 09:03:53.383] [info] [electron-main/api/endpoints-builders/database] dbIndexerOn() action.type: ipc_main_api_db_indexer_on:ProgressState [2019-02-19 09:03:53.383] [verbose] [electron-main/api/endpoints-builders/database] dbIndexerOn() ProgressState.status: {"indexing":true} [2019-02-19 09:03:53.384] [info] [electron-main/database] dump() [2019-02-19 09:03:53.384] [info] [electron-main/database] iterateAccounts() [2019-02-19 09:03:53.397] [info] [electron-main/api/endpoints-builders/database] dbIndexerOn() action.type: ipc_main_api_db_indexer_on:ProgressState [2019-02-19 09:03:53.397] [verbose] [electron-main/api/endpoints-builders/database] dbIndexerOn() ProgressState.status: {"indexing":false}

Thanks for your time!

@vladimiry
Copy link
Owner

vladimiry commented Feb 19, 2019

Looks like out of memory failure at first glance. I guess your account has got a lot of emails? The app by design keeps the entire local store feature related database in memory (main app process), some details.

Does it fail only if the local store feature is enabled for the account (app restart is needed if option got toggled off)?

Does it fail soon after app starting or after a while?

Can you try running the app in console this way for now:

ELECTRON_ENABLE_LOGGING=true `which email-securely-app` 2>&1 | tee ~/email-securely-app.log

It will print extended logs to ~/email-securely-app.log so you could locate some useful information there.

I'm going to enable configurable max_old_space_size option support, defaults to 2048 (2GB).

@vladimiry
Copy link
Owner

Can you also try the app with another account that doesn't have a lot of emails, if you have such account?

@vladimiry
Copy link
Owner

To recap, in your case the app fails after 189.19 seconds (~ 3 minutes) since default node memory limit (~ 1GB) is to low to hold the entire emails database.

Can you try running the app using the following way and let me know how it goes?

`which email-securely-app` --js-flags="--max-old-space-size=4096"

This will set memory limit to 4GB for the main process which holds the emails database.

If that won't be enough I will be ready to provide a solution for increasing memory limit for the renderer processes too.

@vladimiry
Copy link
Owner

Besides I didn't initially notice this stuff <Very long string[340707643]>. So the failure could happen because a too long string was used as currently the database file is being serialized/deserialized as just JSON.stringify/JSON.parse calls and Node.js has limit for the string size. Handling this issue will require introducing stream database file processing.

@vladimiry
Copy link
Owner

vladimiry commented Feb 21, 2019

@internalkernel can you try this build? This build got improved local database serialization.

If it still fails please run the app the following way and send log file to the email specified here in author property:

ELECTRON_ENABLE_LOGGING=true `which email-securely-app` --js-flags="--max-old-space-size=5120"  2>&1 | tee ~/email-securely-app.log

Plus change --max-old-space-size=2048 to --max-old-space-size=3072 or --max-old-space-size=4096 in the config.json.

@internalkernel
Copy link
Author

Sorry about the slow reply here... and thanks for your attention! I'll try to address everything in order.

Indeed it works fine when Local Store is disabled. Running the app with:

ELECTRON_ENABLE_LOGGING=true which email-securely-app 2>&1 | tee ~/email-securely-app.log

results in a out of memory error:

[12521:0220/202508.806543:INFO:CONSOLE(16)] "[20:25:08.805] [preload: database-indexer] [index] dbIndexerNotification.next, action.type: ipc_main_api_db_indexer_notification_actions:Index", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/database-indexer.js (16) [12521:0220/202508.806559:INFO:CONSOLE(16)] "[20:25:08.805] [preload: database-indexer] [index] action.Index() Received mails to remove/add: 0/0", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/database-indexer.js (16) [12521:0220/202508.806571:INFO:CONSOLE(16)] "[20:25:08.806] [electron-main/api/endpoints-builders/database] dbIndexerOn() action.type: ipc_main_api_db_indexer_on:ProgressState", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [12521:0220/202508.806587:INFO:CONSOLE(16)] "[20:25:08.806] [electron-main/api/endpoints-builders/database] dbIndexerOn() action.type: ipc_main_api_db_indexer_on:ProgressState", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/database-indexer.js (16) [12521:0220/202508.806598:INFO:CONSOLE(16)] "[20:25:08.806] [electron-main/api/endpoints-builders/database] dbIndexerOn() ProgressState.status: {"indexing":true}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [12521:0220/202508.806614:INFO:CONSOLE(16)] "[20:25:08.806] [electron-main/api/endpoints-builders/database] dbIndexerOn() ProgressState.status: {"indexing":true}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/database-indexer.js (16) [12521:0220/202508.822278:INFO:CONSOLE(16)] "[20:25:08.807] [electron-main/database] dump()", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [12521:0220/202508.822304:INFO:CONSOLE(16)] "[20:25:08.807] [electron-main/database] iterateAccounts()", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [12521:0220/202508.822647:INFO:CONSOLE(16)] "[20:25:08.807] [electron-main/database] dump()", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/database-indexer.js (16) [12521:0220/202508.822664:INFO:CONSOLE(16)] "[20:25:08.807] [electron-main/database] iterateAccounts()", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/database-indexer.js (16) [12521:0220/202509.988898:ERROR:atom_bindings.cc(48)] Fatal error in V8: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

The second suggestion to increase max_memory helped:

which email-securely-app --js-flags="--max-old-space-size=4096"

It ran for a good hour or two, indexed many of the messages and then crashed with the same error as before, i.e. <Very long string[340707643]>

The new build you linked (thanks by the way), unfortunately didn't make it past the login window initially. I deleted all my settings for the app and installed clean and it is currently working. I'll update with more progress later...

Thanks!

@vladimiry
Copy link
Owner

vladimiry commented Feb 21, 2019

The new build you linked (thanks by the way), unfortunately didn't make it past the login window initially.

The provided build is supposed to be backward compatible (means no breaking changes have been made). Did you happen to keep the log file with the failed login window action?

@internalkernel
Copy link
Author

I did, it was brief... In hindsight, it might have been parsing the current database? I did keep the old profile, I can always restore and try to run it again.

[26138:0221/055632.202985:ERROR:sandbox_linux.cc(379)] InitializeSandbox() called with multiple threads in process gpu-process. [26109:0221/055632.303610:WARNING:app_indicator_icon.cc(279)] Could not encode icon [26109:0221/055632.540899:INFO:CONSOLE(16)] "[05:56:32.534] [WEB] [navigation.effects.ts] <angular> {"actionType":"navigation:Go"}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [26109:0221/055632.540943:INFO:CONSOLE(16)] "[05:56:32.535] [WEB] [navigation.effects.ts] <angular> {"actionType":"navigation:Go"} {"path":[{"outlets":{"settings-outlet":"settings"}}]}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [26109:0221/055632.561601:INFO:CONSOLE(16)] "[05:56:32.560] [WEB] [options.effects] <angular> {"actionType":"options:InitRequest"}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [26109:0221/055632.573671:INFO:CONSOLE(16)] "[05:56:32.570] [WEB] [navigation.effects.ts] <angular> {"actionType":"navigation:Go"}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [26109:0221/055632.573685:INFO:CONSOLE(16)] "[05:56:32.570] [WEB] [navigation.effects.ts] <angular> {"actionType":"navigation:Go"} {"path":[{"outlets":{"settings-outlet":"settings"}}]}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [26109:0221/055632.573696:INFO:CONSOLE(16)] "[05:56:32.572] [WEB] [options.effects] <angular> {"actionType":"options:GetConfigRequest"}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [26109:0221/055632.577445:INFO:CONSOLE(16)] "[05:56:32.574] [WEB] [navigation.effects.ts] <angular> {"actionType":"navigation:Go"}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [26109:0221/055632.577456:INFO:CONSOLE(16)] "[05:56:32.574] [WEB] [navigation.effects.ts] <angular> {"actionType":"navigation:Go"} {"path":[{"outlets":{"settings-outlet":"settings"}}]}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [26109:0221/055632.577470:INFO:CONSOLE(16)] "[05:56:32.576] [WEB] [options.effects] <angular> {"actionType":"options:GetSettingsRequest"}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [26109:0221/055632.625973:INFO:CONSOLE(16)] "[05:56:32.577] [WEB] [navigation.effects.ts] <angular> {"actionType":"navigation:Go"}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [26109:0221/055632.626007:INFO:CONSOLE(16)] "[05:56:32.577] [WEB] [navigation.effects.ts] <angular> {"actionType":"navigation:Go"} {"path":[{"outlets":{"settings-outlet":"settings/login"}}]}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [26109:0221/055632.703478:INFO:CONSOLE(16)] "[05:56:32.589] [WEB] [options.effects] <angular> {"actionType":"options:SignInRequest"}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [26109:0221/055632.915625:INFO:CONSOLE(16)] "[05:56:32.915] [electron-main/database] loadFromFile()", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16)

2.3.3 is running solid, about a 1/3rd of the emails are indexed so far... Thanks!

@vladimiry
Copy link
Owner

vladimiry commented Feb 21, 2019

Would be great to see the lines after these (it's begining of the signing process)

[26109:0221/055632.703478:INFO:CONSOLE(16)] "[05:56:32.589] [WEB] [options.effects] <angular> {"actionType":"options:SignInRequest"}", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16) [26109:0221/055632.915625:INFO:CONSOLE(16)] "[05:56:32.915] [electron-main/database] loadFromFile()", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16)

it might have been parsing the current database?

It does parse the database used/created by the previous app version, but I did care about backward compatibility, see read method implementation. Besides that new build loads the database serialized in JSON from the buffer using https://www.npmjs.com/package/oboe instead of just parsing a long string by calling JSON.parse.

Anyway, I'm going to double check the backward compatibility before releasing a new version.

@internalkernel
Copy link
Author

That was the end of the log, the app stalled at that point... I gave it about a minute or two, I could let it sit longer if that's helpful...

@vladimiry
Copy link
Owner

vladimiry commented Feb 21, 2019

I could let it sit longer if that's helpful...

Please do if that's possible. I guess https://www.npmjs.com/package/oboe could potentially parse the data slower than regular JSON.parse. The default timeout for signing-in action is 25 seconds by the way which can be tweaked in config.json by editing timeouts.defaultApiCall value (app restart is required). Signing-in action includes the database.bin file loading process. If signing in action fails you will get either timeout error or some logic error.

By the way, what is your database.bin file size?

@internalkernel
Copy link
Author

internalkernel commented Feb 21, 2019

Adjusted timeouts to allow for a 10 min window, it crashed after about 3 min... The auto-login feature is turned on.

Link to the full log: https://pastebin.com/zwvkdDF0

I then tried to go back to the newer profile, but the app crashed almost immediately upon launching. Here's that log: https://pastebin.com/fg2afAre

The good news is that I haven't seen another crash, not since running the 2.3.3 build and increasing max_memory to 3072. Database.bin was about 500MBs. both profiles were comparable.

@vladimiry
Copy link
Owner

vladimiry commented Feb 21, 2019

Thanks for the thoughtful report, it helps to make the app work better.

Link to the full log: https://pastebin.com/zwvkdDF0

I see that database file got loaded successfully in 141911ms (~142 sesonds ~ 2.4 minutes which is very slow, hope new serialization in 2.3.3 works faster) but I will need to look into the why the sign-in process finally failed:

[29436:0221/124451.286950:INFO:CONSOLE(16)] "[12:44:51.286] [electron-main/database] loadFromFile()", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16)
[29436:0221/124713.203502:INFO:CONSOLE(1)] "Error: Failed to log in", source: file:///opt/email-securely-app/resources/app.asar/app/web/app.js?b8a97f51d83d358bfdc5 (1)
[29436:0221/124714.473179:INFO:CONSOLE(16)] "[12:47:13.197] [electron-main/database] stat()", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16)
[29436:0221/124714.473201:INFO:CONSOLE(16)] "[12:47:13.197] [electron-main/database] iterateAccounts()", source: /opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js (16)
[29436:0221/124714.473209:INFO:CONSOLE(16)] "[12:47:13.201] [electron-main/database] loadFromFile().stat: {"records":1,"conversationEntries":0,"mails":14165,"folders":60,"contacts":349,"time":141911}", source: /opt/email-securely-

but I will need to look into the why the sign-in process finally failed

Can you try disabling the full-text search feature and give it another try (either via UI or manually in config.json file)? The guess is that sending a huge portion of data from the main process which holds the database to the indexing process is heavily blocking the interaction between processes and so sign-in handler can't respond with completion signal. If so then I will need to chunk the data sending to the parts or enable the search index persisting and the handle the persisted index independently by the indexing process not involving inter-process communication at this stage.

If the bootstrap/initial fetch got completed using the 2.3.3 version (icon stopped blinking in green) does the app work well after the restart with full-text search feature enabled? Asking since the app sends almost the entire database to the indexing process on start and so the interaction between processes would be blocked in the same way.

Database.bin was about 500MBs

Thanks for this info.

I also see that you got 14165 emails saved in the local database ("mails":14165), the biggest database we have seen so far (the previous record was 6161 emails, CC @uberneko), which is a great challenge for the app.

Going to try filling my database with fake data making its size close to 14165 emails and debug the stuff then.

@vladimiry
Copy link
Owner

Can you try disabling the full-text search feature and give it another try (either via UI or manually in config.json file)?

No need to do this as I tested full-text search bootstrapping on 20k mails database and noticed that issue is in something else. So going to provide updated build.

@vladimiry
Copy link
Owner

@internalkernel I just have updated the build here. The build comes with the following changes:

  • Loading the local database now occurs in a separate from the signing-in API call. The default timeout for this call is set to 5 minutes (300000 ms), see timeouts.databaseLoading value in config.json file (file will be updated with default value on the first app start). This change is aimed to improve backward compatibility, the case when the app loads the database saved in the old format by previous app versions (regular JSON vs enabled with v2.3.3 MessagePack format). The app will show Local database is being loaded... Please wait up to 300 seconds-like message while the database file is being loaded.
  • The app should not heavily hang anymore when you switch the account with a huge number of emails to the database view mode (your case). There is still a room for database view mode UI improvement though, especially in the terms of performance improvement on large datasets, but it should be already somehow usable as opposed to v2.3.2.

@internalkernel
Copy link
Author

Thanks again for the new build and happy to help here... Do I win a prize for having the most emails? Beyond a bloated database... :) Gotta love project management, 90% of what I do feels like babysitting.

After installing the updated build, I tried loading the profile from 2.3.2. The app sits on the "Loading Database for 300 seconds" message, then crashed after about 3-4 min. Not sure if that's helpful, since the profile database was part of a previous crash. And, full log from that run: https://pastebin.com/F1uj579u

I'll try the new build on a fresh profile, the other 2.3.3 build would index everything but crash upon reopening the database. I'll see if that has changed this time around as well.

In case it's worth mentioning, I noticed that the message count in the Database view never exceeded 6522 emails - even though the Log output is counting upwards of 15K.

Thanks again for your time and effort here... it is much appreciated!

@vladimiry
Copy link
Owner

vladimiry commented Feb 22, 2019

https://pastebin.com/F1uj579u

Unfortunately, there are no errors in this log which makes it harder to figure the cause of the crash. But it's clear that a database file has been successfully loaded and the app then switched to the accounts view screen (next screen after the login form). So 2.3.3 is backward compatible with previous versions as database got loaded. There is a need to focus on making 2.3.3 work with a large loaded database.

For now, I can just suggest disabling the full-text search feature.

message count in the Database view never exceeded 6522 emails

Do you observe 6522 value on All Mail (6522) folder?

@internalkernel
Copy link
Author

Disabling Full Text Search and everything runs smooth... 2.3.3 runs fine once that's disabled and I tried the old 2.3.2 profile with Full Text Search disabled and that launched fine after importing the database as well.

The 6522 was on the All Mail Folder, but only in 2.3.2 during the first index (before the crash). It shows the complete email list in 2.3.3. with the correct count.

Thanks once again!

@vladimiry
Copy link
Owner

vladimiry commented Feb 24, 2019

Ok, so I will be improving full-text search bootstrapping on large datasets.

Even though 2.3.3 is not released yet it's better to use it on large datasets as it has already got some improvements.

@vladimiry
Copy link
Owner

vladimiry commented Feb 26, 2019

Disabling Full Text Search and everything runs smooth... 2.3.3 runs fine once that's disabled

@internalkernel can you enable full-text search feature and then run updated build? If still fails try changing "--max-old-space-size=2048" to "--max-old-space-size=3072" in config.json.

I tested the updated build on ~50k emails database and it worked well. The previous build was failing on the same database.

@internalkernel
Copy link
Author

On the new build, with Full Text Search enabled... I'm getting the Java Heap out of memory errors, it does take awhile to get there though - at the moment max-old-space is set to 4096, it takes close to 6-8 hours before it hits that point. As of this morning, I disabled Full Text Search to see if it makes a difference in the out of memory errors.

All other aspects appear to be working as intended, the database view shows all emails and the interface is quick / responsive.

@vladimiry
Copy link
Owner

vladimiry commented Feb 28, 2019

Would be great to monitor the app for a while so we could detect which process eagerly and incrementally eating the memory. Such monitoring can be accomplished by running the following commands:

  1. Execute:
    ELECTRON_ENABLE_LOGGING=true `which email-securely-app` --js-flags="--max-old-space-size=4096" 2>&1 | tee ~/email-securely-app.log.
    This will run the main process with --max-old-space-size=4096 argument and enable the extended loging (unfortunately --max-old-space-size argument specified in config.json doesn't affect the main process but only the renderer processes). Also please make sure logLevel in config.json is set to verbose mode.
  2. Right after signin-in into the app execute the following command in another terminal:
    watch -n 30 'echo $(date) >> ~/email-securely-app.watch.log && ps -ewwo pid,etime,rss,%cpu,cmd --sort -rss | grep email-securely-app | grep -v -P '\''grep\s|watch\s|tee\s'\'' | awk '\''{$3=int($3/1024)"MB";}{print;}'\'' >> ~/email-securely-app.watch.log'.
    This will append the resources consuming processes information to ~/email-securely-app.watch.log file every 30 seconds.

Then after the crash please send both log files to the email specified here in the author section or attach here as a file or upload to pastebin service like you did before.

it takes close to 6-8 hours before it hits that point
I'm getting the Java Heap out of memory errors, it does take awhile to get there though - at the moment max-old-space is set to 4096, it takes close to 6-8 hours before it hits that point.

My guess is that it's either --preload=/opt/email-securely-app/resources/app.asar/app/electron-preload/database-indexer.js or --preload=/opt/email-securely-app/resources/app.asar/app/electron-preload/browser-window.js process causing the out of memory crash. The second case is the main app's rendering process which includes the database explorer UI. This process currently loads the content of all the folders to the memory. Which means the pagination is currently occurs at the client-side rather than at the server-side. If we confirm that it's the browser-window.js related process eating the memory then I will need to tweak that pagination. It will also mean that the app will crash after a while even if the full-text search feature is disabled depending on database view mode use intensity.

The most recent build is uploaded here. It doesn't include new fixes yet but only some dependencies and tutanota's webclient updating.

@internalkernel
Copy link
Author

Installed the updated build and launched as you suggested (attached logs in the email sent).

In the last run, I only used the Database view once to check the amount of indexed emails. I haven't used it to extensively yet, if that makes a difference with memory usage.

@vladimiry
Copy link
Owner

vladimiry commented Mar 1, 2019

I've detected some pattern looking into the provided logs.

Please, for now, disable the local store feature and restart the app as it's not ready to handle so huge mails database at the moment and so it creates higher than intended load on the protonmail's servers performing more than one bootstrap fetch action in parallel even though there is only one account added to the app (this is also a reason why memory use of the electron-preload/webview/protonmail.js process got increased up to 3483MB).

If you want you can backup somewhere the database.bin file before disabling the local store feature but it will be useless since bootstrap fetch has never been completed for you and so the app will start bootstrap fetch again from the beginning like database doesn't exist.

@vladimiry
Copy link
Owner

vladimiry commented Mar 1, 2019

Updated build is here. Steps to perform:

  • Remove or rename database.bin file, so the app makes a clean start.
  • Change --max-old-space-size=3072 to --max-old-space-size=5120 in config.json.
  • Run ELECTRON_ENABLE_LOGGING=true `which email-securely-app` --js-flags="--max-old-space-size=5120" 2>&1 | tee ~/email-securely-app.log.
  • Run watch -n 30 'echo $(date) >> ~/email-securely-app.watch.log && ps -ewwo pid,etime,rss,%cpu,cmd --sort -rss | grep email-securely-app | grep -v -P '\''grep\s|watch\s|tee\s'\'' | awk '\''{$3=int($3/1024)"MB";}{print;}'\'' >> ~/email-securely-app.watch.log'.

Specified memory limits look huge but let's monitor the real values running new build.

The bootstrap fetch process is going to take roughly 3-6 hours for your ~18k messages, not because the app is slow but because it has to respect rate limiting set by protonmail.

In the last run, I only used the Database view once to check the amount of indexed emails. I haven't used it to extensively yet, if that makes a difference with memory usage.

You can use the database view mode extensively or just keep in open while the database is being bootstrapped (new messages will get there dynamically by portions of ~500 messages each).

@internalkernel
Copy link
Author

I think you got it this time... I was able to run the app all day without crashing, and memory usage remained stable as well. I clicked around the Database view on several occasions attempting to use it as much as possible as well. Also noticed that the Database view seemed to finish downloading the message store as well.

Thanks once again!

@vladimiry
Copy link
Owner

vladimiry commented Mar 4, 2019

I think you got it this time.

Because the full logs you provided last time helped a lot as well as your willingness to cooperate in investigating the case.

Based on the logs it took 2 hours and 24 minutes to complete the database bootstrap fetch process. The app fetched 18252 email messages during that time. Bootstrapping is a one-off/initial action which means that after it got completed the app will only reactively fetch small database patches.

The main app's process takes 1992MB based on the final log line. I think it's higher than the default nodejs's memory limit which means most likely you will have to run the app like this `which email-securely-app` --js-flags="--max-old-space-size=N" (where N is a value bigger than 2GB, like 3072/4096/etc). By the way, you can try adding this argument to the app shortcut. But first try running without any arguments in the command line or using default shortcut, maybe the app won't hit the default nodejs's memory limit.

I will think how to make the max mem of the main process configurable without a need to pass the argument but taking the config params from config.json (it's currently only possible for the renderer process). Maybe using something like simple preloader or hardcoding the argument to the shortcut.

Going to publish a new release soon. It will consume a little less memory since I've recently fixed a memory leaking issue in https://github.com/vladimiry/electron-rpc-api.

Closing as resolved.

@vladimiry
Copy link
Owner

Implemented improvements releases with v2.3.3 build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants