2

I have an old program that started crashing recently, it only crashes on this particular pc running windows 7 x64 ultimate (I tried this program on another installation of Windows 7 x64 ultimate and there it works completly fine)

It crashes early due to acsess violation (c0000005) in msvcrt.dll

I have the source code for it: https://ftp.mozilla.org/pub/mozilla/releases/mozilla1.7.2/src/mozilla-source-1.7.2.tar.gz and here is the binary I am testing against: https://ftp.mozilla.org/pub/mozilla/releases/mozilla1.7.2/mozilla-win32-1.7.2.zip

it crashes on from_strstr_to_strchr() function in msvcrt.dll

Visual Studio Debugger only shows me the dissasembly for msvcrt.dll and stacktrace starts there, it doesn't show me where firefox called this function and what data it passed to it...

I tried to add source code in solution->Common properties->Debug source files but it still says Source code not uvailable (Source information is missing from the debug information for this module), I even tried to go to Options->Debugging and unchecked Require source code to be an exact match the original version, but visual studio still does not use the source code

I though ok, maybe its because I am trying to debug a release build, so I went and compiled firefox from source

this is the .mozconfig options I used

ac_add_options --disable-tests
ac_add_options --without-system-nspr
ac_add_options --without-system-zlib
ac_add_options --without-system-jpeg
ac_add_options --without-system-png
ac_add_options --without-system-mng
ac_add_options --enable-crypto 

the problem is I cannot build firefox and debug it on the same machine (because on my build machine it works of course), and once I move it to my test machine it doesn't start because its missing msvcrtd.dll (and even if I provide it the dll from the internet or from my development machine it crashes (probably because DLL is for Visual C++ 6 and I have Visual C++ 2008 runtime installed on my test machine)

So how do I tell visual studio to debug an exe, provide it with the source code and let it show me on what function does the crash accour and what was the input to that function (I am suspecting its eather some file or registry entry that is somewhere on that pc that this old firefox is trying to read and failing), I even tried to uninstall and reinstall firefox (but sadly its installer never cleans everything up), even used Revo uninstaller to clean everything that it found, even trying to uninstall all the Visual C++ runtimes I found and reinstalled them again, but nothing...

Hope someone can help me because it drives me crazy (and yes, I need that version of firefox for a very old company application we are using....)

What is wierd the most is that firefox used to work a while ago, but then it just started to crash suddenly

Andreas Wenzel
  • 22,760
  • 4
  • 24
  • 39
LimetaPeta
  • 67
  • 5
  • In your question, you wrote: "and even if I provide it the dll from the internet or from my development machine it crashes" -- Is that not what yoiu want? Don't you want the debug build of the program to crash, just like the release build crashes, so that you can reproduce the bug? Did you expect the program to crash in a different way? – Andreas Wenzel Oct 15 '22 at 21:05
  • yes, the program does crash, but at the start, it doesn't even write anything to the console (in debug mode firefox shows a console what its doing) and when I tried to debug it with visual studio again it only shows the dissasembly of msvcrtd.dll not the function that called this export – LimetaPeta Oct 15 '22 at 21:16
  • Does the debug build also give you an access violation (error code `c0000005`)? Or what exactly do you mean with "crash"? – Andreas Wenzel Oct 15 '22 at 21:30
  • yes the debug build also gives me this: access violation (c0000005) and by crash I mean that the program exits and I get the program has stopped working dialog in windows I am realy not sure anymore how to debug things like this anymore (if I could see what part of firefox code this happens I would have a better understanding, or is there any other way maybe?) – LimetaPeta Oct 15 '22 at 21:36
  • It is possible that the program is crashing even before the first line of `main` is being executed. It could be crashing in the startup code of the C++ runtime library (msvcrt) or the function `DllMain` of a DLL that the program is using, as these are executed before `main`. You could test this by inserting a call to [`OutputDebugString`](https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringa) to the start of the function `main` in the source code and then compiling it again. If a debugger is attached, it should display all `OutputDebugString` events. – Andreas Wenzel Oct 15 '22 at 21:50
  • can you elaborate a little bit, I am a bit confused, since this function is already defined in mozilla\js\jsd\jsd_scpt.c (line 176) and there is a lot of main methods in firefox codebase (not even sure which one to choose :) ) also what should I look for after I manage to find the right main method and inject OutputDebugString into it? I did try to inject my dll with AppInit_DLL and it is injected and it does produce a test txt file (so maybe I could somehow use it to help me debug this problem?) also can I maybe follow a stack of dlls and figure out which one is causing the crash? – LimetaPeta Oct 15 '22 at 22:17
  • I am unfortunately unfamiliar with the Firefox source code. It is possible that it is using a different code entry point than `main`, as most compilers allow you to change it. However, my guess is that the code entry point actually is called `main`. The Firefox source code probably contains code to build many programs, not just `Firefox.exe`. It is possible that is why you are finding many functions called `main`. If it is `Firefox.exe` that is crashing, then you should concentrate on the source code for that program. – Andreas Wenzel Oct 15 '22 at 22:28
  • When I call `OutputDebugString` in a program with the Visual Studio 2017 debugger attached, it appears in the "Output" window of my debugger. I am not sure if it is the same with the debugger you are using. You may want to create a small test program to see how `OutputDebugString` behaves with your debugger. – Andreas Wenzel Oct 15 '22 at 22:34
  • In the question, you state that "it crashes on from_strstr_to_strchr() function in msvcrt.dll". This information applies to the release build. Do you get any such information for the debug build, when the program crashes inside the debugger? – Andreas Wenzel Oct 15 '22 at 22:44
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/248837/discussion-between-andreas-wenzel-and-limetapeta). – Andreas Wenzel Oct 15 '22 at 22:58
  • You mention that firefox works OK on one machine and fails on another machine. Both machines are running the same OS. Have you tried starting firefox on each machine in the visual studio debugger and then examining the loaded modules window? You can check the versions of the DLLs in the succeeding firefox and those in the failing firefox - then you can isolate which DLLs are different builds. Perhaps that will shed some light on your problem? – Stephen Kellett Oct 17 '22 at 21:51
  • well things are becoming wierd now, yesterday it worked fine I didn't take a backup because I thought that it will last at least a day, well, one reboot later (one day later) and we are back at square one if only I would take the backup when it worked so I could compare.... what could change in a day (one reboot) that would break firefox? (what....) I will try to remote debug now (I cannot local debug because I cannot figure out how to build this old firefox with new build tools :) ) – LimetaPeta Oct 18 '22 at 20:48

0 Answers0