Skip to content

[Bug]: Crash on attaching the file using generic input type="file" form control #30858

Description

@vladimiry

Preflight Checklist

Electron Version

15.0.0-beta.2

What operating system are you using?

Linux 5.13.13 kernel

What arch are you using?

x64

Last Known Working Electron version

14.0.0

Expected Behavior

The app doesn't crash.

Actual Behavior

The app crashes.

Testcase Gist URL

https://github.com/vladimiry/ElectronMail/releases/tag/v4.12.6

Additional Information

It's not so trivial task to create an isolated repro for the case like this, but link to the app release has been attached as well as the crash stack.

Downgrading 15.0.0-beta.2 => 14.0.0 resolves the issue.

See attached crash stack.

Activity

  1. changed the title [-][Bug]: Coredump on attaching the file to draft email using ElectronMail v4.12.6[/-] [+][Bug]: Crash on attaching the file to draft email using ElectronMail v4.12.6[/+] on Sep 6, 2021
  2. VerteDinde commented on Sep 7, 2021

    @VerteDinde
    Member

    Hey @vladimiry, thanks for reporting this issue! Sorry, I know this is easier said than done, but is there any way for you to make a minimal repro of the issue for our maintainers to use for testing? I tried to create a minimal Fiddle repro using a native dialog to open file attachments, but haven't been able to reproduce the issue; even if you could point me to where in ElectronMail you handle dialogs, that would be very appreciated 🙇‍♀️

    One other question: could you try downgrading from 15.0.0-beta.2 to 15.0.0-alpha.9? We have a similar report on Windows that seems to appear beginning in 15.0.0-alpha.10, and I'm curious if this could have the same root cause.

    Thanks so much!

  3. vladimiry commented on Sep 7, 2021

    @vladimiry
    Author

    Hi @VerteDinde, thanks for thorough clarifying questions. Not promising that I will be able to provide a minimal isolated repro project but I should be able to address rest of the points you raised within the next 3 days.

    even if you could point me to where in ElectronMail you handle dialogs, that would be very appreciated

    The ElectronMail itself triggers the file system-related dialog I think only in one place - selecting a destination folder for batch emails exporting (being handled in the main process here). This requires the account to be added into the app and the local store option to be enabled for that account (so you then switch to the "local store" mode and do export stuff).

    But the app comes with an embedded https://github.com/ProtonMail/WebClients web clients stack which might potentially have a lot of file system-related dialog opening entry points. One of such entry points is adding the attachment to the draft email - you just compose a new email and attach any file and it gets crashed without showing the dialog (yes I've initially noticed that some dialog things are mentioned in the stack trace). This entry point, just composing new email and adding the attachment, is how the issue got noticed by the end-user. It's by the way unclear yet what system was used by that user (I've asked for details). For that user that could potentially be Windows, but I was able to reproduce the issue on Linux.

  4. vladimiry commented on Sep 7, 2021

    @vladimiry
    Author

    The ElectronMail itself triggers the file system-related dialog I think only in one place - selecting a destination folder for batch emails exporting

    I've just tested the above-quoted case using https://github.com/vladimiry/ElectronMail/releases/tag/v4.12.6 on Linux and there is no crash when I select the destination folder via file system dialog (this code). So for now I can only say that it crashes during adding an attachment to email - so file selecting dialog triggered from the embedded into webview WebClients client/page. So not folder selecting, but file, and also might potentially be webview-specific. I understand that this information is not very helpful but still believe it narrows down the scope.

  5. vladimiry commented on Sep 8, 2021

    @vladimiry
    Author

    you just compose a new email and attach any file and it gets crashed without showing the dialog

    I was of course wrong here. It of course shows the dialog and crashes after the file/files get selected.

    One other question: could you try downgrading from 15.0.0-beta.2 to 15.0.0-alpha.9? We have a similar report on Windows that seems to appear beginning in 15.0.0-alpha.10, and I'm curious if this could have the same root cause.

    Can confirm that 15.0.0-alpha.9 doesn't crash but 15.0.0-alpha.10 does.

  6. vladimiry commented on Sep 8, 2021

    @vladimiry
    Author

    @VerteDinde it crashes even for the following simple snippet (even without webview involving), so should be easy to reproduce. I didn't compare the stacktraces though but it's likely the same issue (crashes starting from 15.0.0-alpha.10).

    const {app, BrowserWindow} = require('electron')
    
    app.whenReady().then(() => {
      new BrowserWindow().loadURL(`data:text/html,
        <html>
        <body>
        <form method="post" enctype="multipart/form-data">
            <input type="file" name="file" multiple>
        </form>
        </body>
        </html>
      `)
    })
  7. self-assigned this
    on Sep 8, 2021
  8. nornagon commented on Sep 8, 2021

    @nornagon
    Contributor

    cc @codebytere. Possibly #30663 is relevant (might fix this issue?).

  9. codebytere commented on Sep 8, 2021

    @codebytere
    Member

    @nornagon i imagine it might though it might be a pain/unwise to backport so I can look to fix this as a one-off pending that larger PR being merged

  10. VerteDinde commented on Sep 8, 2021

    @VerteDinde
    Member

    @codebytere The root of the issue seems to be in this block within FileSelectHelper::OnOpenDialogDone:

          if (render_frame_host_ && !paths.empty()) {
            auto* browser_context = static_cast<electron::ElectronBrowserContext*>(
                render_frame_host_->GetProcess()->GetBrowserContext());
            render_frame_host_->GetProcess();
            browser_context->prefs()->SetFilePath(prefs::kSelectFileLastDirectory,
                                                  paths[0].DirName());
          }
    

    I think this Chromium roll between 15.0.0-beta.9 and 15.0.0-beta.10 broke it, since it seems to be broken on both Windows and Linux. Mac is unaffected: #30370 Trying to find a fix now. (FWIW, the above repro doesn't work for me in Fiddle on Windows).

  11. vladimiry commented on Sep 8, 2021

    @vladimiry
    Author

    FWIW, the above repro doesn't work for me in Fiddle on Windows

    I ran it on Linux only.

  12. codebytere commented on Sep 8, 2021

    @codebytere
    Member

    @vladimiry also reproduces on Linux for me, thanks!

  13. changed the title [-][Bug]: Crash on attaching the file to draft email using ElectronMail v4.12.6[/-] [+][Bug]: Crash on attaching the file using generic input type="file" form control[/+] on Sep 9, 2021
  14. VerteDinde commented on Sep 13, 2021

    @VerteDinde
    Member

    @vladimiry I think my merging the fix PR automatically closed this issue, but should be addressed in 15-beta.5, which will release in a few hours! Could you let me know if you still see the behavior after beta.5 is released? If it persists, I'll reopen the issue.

    Thanks again for reporting this! 🙇‍♀️

  15. vladimiry commented on Sep 13, 2021

    @vladimiry
    Author

    @VerteDinde the issue appears to be fixed for me in 15-beta.5 on Linux. Thanks everyone involved into fixing it.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions