dannyedel / dspdfviewer

Dual-Screen PDF Viewer for latex-beamer
http://dspdfviewer.danny-edel.de
GNU General Public License v2.0
218 stars 27 forks source link

MSVC Dynamic/Debug build crashes #154

Closed dannyedel closed 8 years ago

dannyedel commented 8 years ago

Using the prebuilt dependencies from #147, building in Debug mode results in a Stack Overflow.

Current Working Theory:

A library in release mode new'd the pointer, but we delete it in Debug mode, triggering the "Was this memory block alloc'd with (debug) new" and the double-free check, which both fail since the memory block was never put into the list.


Debug this and spawn a new PR that enables AppVeyor to test both Debug and Release mode.

dannyedel commented 8 years ago

@projekter this batch script reproduces the "Stack overflow" crash for me.

https://gist.github.com/dannyedel/9bdbcb2e44e568ba1c39

Win7 VM state before running script:

I called the batch script from inside a "Git CMD", and I use virtualbox's "Shared folders" feature to access my dspdfviewer source as \\vboxsrv\dspdfviewer. A native git checkout somewhere should work too, it's just convenient for me to directly edit my host's directory, since I can throw away and remake the VM whenever I feel like it.

While I'm trying to debug this, can you check whether it also crashes on your system? If it does, it may not be a problem about a DLL missing in the package, but maybe one thing never got built in debug mode.

dannyedel commented 8 years ago

I had a lengthy answer ready and then the power went out. Serisouly. (Note to self: Save money for UPSs also on the workstation, not just the homeserver)

Short story:

strings dspdf/popplerDyn/poppler/lib/poppler-qt5d.lib \
    | grep --only-matching -w .*.dll | sort -u
#output:
poppler-qt5.dll

This looks different than on a Qt5 .lib file:

strings Qt5Cored.lib  | grep --only-matching -w .*.dll | sort -u
#output:
Qt5Cored.dll

@projekter can you check whether the .lib files are supposed to do that?


Loaded modules on testrunner.exe:

modules-loaded-non-dynamic

Checking the "Order" column, Qt5Guid.dll is loaded really early (by testrunner itself), and poppler-qt5.dll is number 24, then Qt5Gui.dll (non-debug version) is loaded as number 25. That would explain why QImage's allocated from within poppler (using Qt5Gui non-debug allocator) but destroyed in testrunner (using Qt5Gui Debug deallocator) cause the crash.

projekter commented 8 years ago

Yes, that's exactly what they are supposed to do. Sorry for this, I should have mentioned it: The applications normally do not have separate libaries, depending on whether they are debug or release compiled. If you want to use the debug libraries, you have to copy them to the application folder and remove the "d" from the filename. That's the only way to enforce their usage.

dannyedel commented 8 years ago

Thanks for the quick answer!

Trying that now :+1:

dannyedel commented 8 years ago

Now it works.

It turns out, copying the debug poppler-qt5d.dll is enough to solve the problem at hand, since now no more library seems to be double-loaded. I'm not sure if I'm in the realm of undefined behaviour here, but now the testsuite walks through without erros and I can call Debug\dspdfviewer.exe and use it.

For reference: Module List now

modules-loaded-debug-poppler-qt5-0


revised batch script:

https://gist.github.com/dannyedel/549e57aa73936d7d7a7f


@projekter does that look OK to you? If yes, I'd implement this on appveyor and then close this ticket.

projekter commented 8 years ago

Compiles and runs all tests without any complaints.