SkyLined / BugId

Detect, analyze and uniquely identify crashes in Windows applications
https://bugid.skylined.nl
Other
500 stars 90 forks source link

BugId incorrectly assumes that Firefox terminates when the main process terminates #94

Closed hos3in-sh closed 3 years ago

hos3in-sh commented 4 years ago

hi in first loop Firefox closes the main process and create another process so First LOOP of fuzzing occur " WindowsError(32, 'The process cannot access the file because it is being used by another process')" exception. my stack :

D:\Fuzzing>fuzz.cmd Running on ClusterFuzz Output directory: d:\Fuzzing\Tests Number of samples: 10 Writing a sample to d:\Fuzzing\Tests\fuzz-00000.html Writing a sample to d:\Fuzzing\Tests\fuzz-00001.html Writing a sample to d:\Fuzzing\Tests\fuzz-00002.html Writing a sample to d:\Fuzzing\Tests\fuzz-00003.html Writing a sample to d:\Fuzzing\Tests\fuzz-00004.html Writing a sample to d:\Fuzzing\Tests\fuzz-00005.html Writing a sample to d:\Fuzzing\Tests\fuzz-00006.html Writing a sample to d:\Fuzzing\Tests\fuzz-00007.html Writing a sample to d:\Fuzzing\Tests\fuzz-00008.html Writing a sample to d:\Fuzzing\Tests\fuzz-00009.html ┌─ Warning ──────────────────────────────────────────────────────────────────────────────────────────────────────────── │ You are running a newer version of Python (2.7.18) in which this version of │ BugId has not been tested yet. The following Python versions have been tested: │ 2.7.14, 2.7.15, 2.7.16, and 2.7.17. │ Please report this so BugId can be tested with this version of Python at: │ https://github.com/SkyLined/BugId/issues/new └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ┌─ Software license warning ─────────────────────────────────────────────────────────────────────────────────────────── │ You have no license for cBugId and your trial period will expire on June 21nd, 2020 │ You have no license for BugId and your trial period will expire on June 21nd, 2020 └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Please report the above details at the below web-page so it can be addressed: https://github.com/SkyLined/BugId/issues/new If you do not have a github account, or you want to report this issue privately, you can also send an email to: BugId@skylined.nl

In your report, please copy the information about the exception reported above, as well as the stack trace and BugId version information. This makes it easier to determine the cause of this issue and makes for faster fixes.

If you can reproduce the issue, it would help a lot if you can run BugId in verbose mode by adding the --verbose command-line argument. as in: BugId -v firefox --sReportFolderPath="d:\Fuzzing\Report" --nApplicationMaxRunTimeInSeconds=50 -- file://d:\Fuzzing\Tests\index.html

┌─ Version information ──────────────────────────────────────────────────────────────────────────────────────────────── │ ∙ BugId version: 2020-01-09 11:00 (in trial period). │ ∙ mFileSystem2 version: 2019-12-20 14:06. │ ∙ mWindowsAPI version: 2019-12-20 14:07. │ ∙ mDebugOutput version: 2019-12-20 14:07. │ ∙ cBugId version: 2019-12-20 14:08 (in trial period). │ ∙ mWindowsSDK version: 2019-12-20 14:06. │ ∙ mMultiThreading version: 2019-12-20 14:07. │ ∙ mDateTime version: 2020-01-09 10:21. │ ∙ mRegistry version: 2019-12-20 14:07. │ ∙ mProductDetails version: 2020-01-09 10:59. │ ∙ oConsole version: 2019-12-20 14:06. │ ∙ Windows version: Windows 10 Pro release 1909, build 18363 x64. │ ∙ Python version: 2.7.18 x64. └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

┌─ Software license warning ─────────────────────────────────────────────────────────────────────────────────────────── │ You have no license for cBugId and your trial period will expire on June 21nd, 2020 │ You have no license for BugId and your trial period will expire on June 21nd, 2020 └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Thank you in advance for helping to improve BugId!

Thank You For Supporting.

SkyLined commented 4 years ago

Sorry about the late reply.

It looks like Firefox is already running. When you start Firefox twice, the second copy terminates. If you want to use BugId with Firefox, make sure all Firefox processes are killed first.

Let me know if this fixes your issue.

h0wl commented 4 years ago

Hi, i just checked by running BugId.cmd firefox and i have the same problem, it seems BugId does not correctly attach to FF and exits instantly (tested with 78.0.1 x64) - thinks FF has terminated, but it actually still runs.

SkyLined commented 4 years ago

My bad; I can reproduce and luckily it is quite easy to fix: Firefox recently started spawning a new process and terminating the original (main) process. BugId assumed that Firefox is terminated when the original (main) process is terminated. You can change this by editing BugId\ddxApplicationSettings_by_sKeyword\ddxMozillaFirefoxSettings_by_sKeyword.py and changing line 8-10 to:

dxConfigSettings = {
  "bApplicationTerminatesWithMainProcess": False,
};

Now when you start Firefox and it terminates the main process, BugId will continue to debug the remaining processes.

I'll create a patch to make this the default.

Thanks for reporting @hos3in-sh and confirming this issue exists @h0wl.

SkyLined commented 4 years ago

Fix is out in release build: https://github.com/SkyLined/BugId/releases/tag/2020-07-01

h0wl commented 4 years ago

hmm, I have the same result after applying that change, doesnt seem to fix it.

SkyLined commented 4 years ago

Odd. Can you please: 1) check with BugId.cmd --version That you are indeed running BugId version 2020-07-02 07:43 2) let me know what version of Firefox you are running. 3) copy+paste the output from BugId firefox so I know what processes get spawned and terminated?

Thanks for the help!

h0wl commented 4 years ago
  1. I applied the change manually as instructed above so i did use the previous version (2020-06-17)
  2. Checked with FF 78.0.1 x64
  3. here's the output (it was the same regardless of the option bApplicationTerminatesWithMainProcess set to True or False):
h0wl commented 4 years ago

just checked with the latest release with the same result - btw the latest release is broken - missing modules in the modules folder.

SkyLined commented 4 years ago
* Command line: C:\Program Files\Mozilla Firefox\firefox.exe --no-remote http://xxx/
* Main process 264220/0x4081C (firefox.exe): Attached; command line = "C:\Program Files\Mozilla Firefox\firefox.exe" --no-remote http://xxx/.
* Main process 264220/0x4081C (firefox.exe): Terminated.

That shows me that firefox.exe does not spawn a child process before terminating, which is weird. It is perfectly normal for BugId to stop when there are no more processes so the real question is: why is firefox not starting additional processes before terminating? Also, I would expect the firefox command line to include -profile <path-to-random-profile>: this is defined in BugId\ddxApplicationSettings_by_sKeyword\ddxMozillaFirefoxSettings_by_sKeyword.py lines 24-29:

def fasGetFirefoxStaticArguments(bForHelp):
  oFirefoxProfileFolder.fCreate();
  return [
    "--no-remote",
    "-profile", oFirefoxProfileFolder.sPath,
  ];

Did you make any other changes?

just checked with the latest release with the same result - btw the latest release is broken - missing modules in the modules folder.

Oops! You are right: that release file is completely broken. I'll fix that asap.

h0wl commented 4 years ago

yeah, i commented out the -profile", oFirefoxProfileFolder.sPath, - this also did not influence results which are the same with or without that parameter.

why is firefox not starting additional processes before terminating

Firefox starts normally after executing BugId.cmd and keeps running, that original process present in the logs gets terminated, however there are definitely other firefox processes created.

SkyLined commented 4 years ago

Can you check that there are no firefox processes running before you start BugId? I seem to recall that Firefox could have a background process running and when you start firefox.exe, it would simply tell the background process to open a new window and terminate. That would explain what you are seeing. Otherwise, I do not have any logical explanation for what is happening.

SkyLined commented 4 years ago

There is also a new release that should have all dependency modules this time.

https://github.com/SkyLined/BugId/releases/tag/2020-07-02

h0wl commented 4 years ago

just tried on a fresh Win10 VM, with the latest version (the release is still broken btw, now its missing the ddxApplicationSettings_by_sKeyword folder :) ) and still getting the exact same result... so no idea what could be wrong.

SkyLined commented 4 years ago

Sorry, I made changes to the code that generates the release zips and obviously do not have unit tests to make sure it still works.

I've uploaded a new release zip. I have no idea what is causing this issue for you, and I don't know when I'll have time to investigate the root cause, sorry. I'll keep this bug open until I've found a solution.

SkyLined commented 4 years ago

Hey, is this bug still open?

SkyLined commented 4 years ago

Asking again if this bug should remain open. Without anyone able to reproduce this issue, I will close it.

h0wl commented 4 years ago

sorry, i'm not actively looking into it, however just checked on latest stable (81.0.2) and the issue still occurs for me.

SkyLined commented 3 years ago

I found some time to look into this and asked the Firefox developers what could be causing this. Turns out it is the result of the process sandboxing/hardening. More details here:

https://wiki.mozilla.org/Platform/Integration/InjectEject/Launcher_Process/#Considerations_for_Developers

It can be avoided by adding the "--wait-for-browser" flag to the Firefox command line. This is now the default through this commit: https://github.com/SkyLined/BugId/commit/b5e6fdcda70d3f48518eb4f510df45cdb51bab86