Bug 326739 - KMyMoney crashes when attempting on-line price update with suspect source parameters.
Summary: KMyMoney crashes when attempting on-line price update with suspect source par...
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: 4.6.4
Platform: Microsoft Windows Microsoft Windows
: NOR crash
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-27 13:49 UTC by allan
Modified: 2014-08-09 20:08 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
A possibly more useful backtrace with kmymoney symbols. (5.76 KB, text/plain)
2013-10-27 17:57 UTC, allan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description allan 2013-10-27 13:49:34 UTC
Debug is installed but when KMM crashes, the only message is Warning: QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
KCrash: Application 'kmymoney.exe' crashing... 

The program starts, the price update is selected, the update window opens and then the crash occurs.

Reproducible: Always

Steps to Reproduce:
1.Create a new investment.
2.Select TPE as the symbol.
3.Select GPW as the source.
4.Select online price update.
Actual Results:  
Crashes, as above.

Expected Results:  
a) Should not crash without a message.
b) Should produce debug info.
Comment 1 allan 2013-10-27 14:01:38 UTC
I've now tried on 4.6.3 and do get some output - 
Application: KMyMoney (kmymoney.exe), signal: EXCEPTION_ACCESS_VIOLATION


[unknown]!KiFastSystemCallRet() [[unknown] @ -1] at 0x7c90e514
[unknown]!Sleep() [[unknown] @ -1] at 0x7c802455
[unknown]!StringFromGUID2() [[unknown] @ -1] at 0x774fe3e3
[unknown]!GetModuleFileNameA() [[unknown] @ -1] at 0x7c80b729


[unknown]!KiFastSystemCallRet() [[unknown] @ -1] at 0x7c90e514
[unknown]!I_RpcBCacheFree() [[unknown] @ -1] at 0x77e76caf
[unknown]!I_RpcBCacheFree() [[unknown] @ -1] at 0x77e76ad1
[unknown]!I_RpcBCacheFree() [[unknown] @ -1] at 0x77e76c97
[unknown]!GetModuleFileNameA() [[unknown] @ -1] at 0x7c80b729


[unknown]!QTextCodec::toUnicode() [[unknown] @ -1] at 0x6713d837
[unknown]![unknown]() [[unknown] @ -1] at 0x646717c2


[unknown]!KiFastSystemCallRet() [[unknown] @ -1] at 0x7c90e514
[unknown]!GetModuleFileNameA() [[unknown] @ -1] at 0x7c80b729


[unknown]!KiFastSystemCallRet() [[unknown] @ -1] at 0x7c90e514
[unknown]!WmiFreeBuffer() [[unknown] @ -1] at 0x77df8631
[unknown]!GetModuleFileNameA() [[unknown] @ -1] at 0x7c80b729


[unknown]!KiFastSystemCallRet() [[unknown] @ -1] at 0x7c90e514
[unknown]!GetModuleFileNameA() [[unknown] @ -1] at 0x7c80b729
Comment 2 allan 2013-10-27 17:57:20 UTC
Created attachment 83161 [details]
A possibly more useful backtrace with kmymoney symbols.
Comment 3 Cristian Oneț 2013-10-28 08:18:13 UTC
OK, I see now, the problem is this line [1]. QTextCodec::codecForName is used wihtou checking if a codec is actually returned. This should be changed to

QTextCodec * codec = QTextCodec::codecForName(prober.encoding());
if (!codec)
  codec = QTextCodec::codecForLocale();
codec->toUnicode(page);

[1] https://projects.kde.org/projects/extragear/office/kmymoney/repository/revisions/4.6/entry/kmymoney/converter/webpricequote.cpp#L138
Comment 4 allan 2013-10-28 11:02:44 UTC
(In reply to comment #3)
> OK, I see now, the problem is this line [1]. QTextCodec::codecForName is
> used wihtou checking if a codec is actually returned. This should be changed
> to
> 
> QTextCodec * codec = QTextCodec::codecForName(prober.encoding());
> if (!codec)
>   codec = QTextCodec::codecForLocale();
> codec->toUnicode(page);
> 
> [1]
> https://projects.kde.org/projects/extragear/office/kmymoney/repository/
> revisions/4.6/entry/kmymoney/converter/webpricequote.cpp#L138

As this works without apparent problem in Linux, but not on Windows, does this suggest that the required codec is not available on Windows for some reason?

There appears to have been no change to this code since pre 4.6, so the user can't revert.  Is this a question of waiting for 4.7, or might there be a new Windows version earlier?  That said, though, 4.6.3 at least crashes more gracefully.
Comment 5 Cristian Oneț 2014-07-31 09:46:52 UTC
This should be fixed since QTextCodec::codecForName.

"Returns 0 if no codec matching the name name could be found."
Comment 6 Cristian Oneț 2014-08-09 20:06:26 UTC
Git commit 26a476404b103fb5020974a165fd64664eb67f1f by Cristian Oneț.
Committed on 09/08/2014 at 20:04.
Pushed by conet into branch 'master'.

Avoid crashing if the detected codec does not exist.

M  +4    -1    kmymoney/converter/webpricequote.cpp

http://commits.kde.org/kmymoney/26a476404b103fb5020974a165fd64664eb67f1f
Comment 7 Cristian Oneț 2014-08-09 20:08:21 UTC
Git commit 2f72c46e476e957070d7fd99030e21b46dd74229 by Cristian Oneț.
Committed on 09/08/2014 at 20:04.
Pushed by conet into branch 'frameworks'.

Avoid crashing if the detected codec does not exist.
(cherry picked from commit 26a476404b103fb5020974a165fd64664eb67f1f)

M  +4    -1    kmymoney/converter/webpricequote.cpp

http://commits.kde.org/kmymoney/2f72c46e476e957070d7fd99030e21b46dd74229