Bug 434605 - crash when importing csv with missing category
Summary: crash when importing csv with missing category
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: importer (show other bugs)
Version: 5.1.1
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-19 05:38 UTC by Martin Tlustos
Modified: 2021-03-28 06:23 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.1.2


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Tlustos 2021-03-19 05:38:03 UTC
SUMMARY
I tried to import a small csv file into an existing kmymoney project. When clicking "import csv file" at the end of the settings dialogue, it crashed with the error "Account has no name /workspace/build/kmymoney/mymoney/mymoneyfile.cpp:950"



STEPS TO REPRODUCE
1. Open kmymoney with the desired project
2. import a small csv file
3. click "import csv file" (both with or without setting options)

OBSERVED RESULT
kmymoney crashes with error "Account has no name /workspace/build/kmymoney/mymoney/mymoneyfile.cpp:950" and the following backtrace

EXPECTED RESULT
the file should be imported without errors

SOFTWARE/OS VERSIONS
Operating System: KDE neon 5.21
KDE Plasma Version: 5.21.3
KDE Frameworks Version: 5.80.0
Qt Version: 5.15.2
Kernel Version: 5.4.0-67-generic
OS Type: 64-bit
Graphics Platform: X11
Processors: 4 × Intel® Core™ i5-7200U CPU @ 2.50GHz
Memory: 7.6 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 620


ADDITIONAL INFORMATION

Application: KMyMoney (kmymoney), signal: Aborted

[New LWP 26153]
[New LWP 26154]
[New LWP 26160]
[New LWP 26161]
[New LWP 26162]
[New LWP 26163]
[New LWP 26165]
[New LWP 26166]
[New LWP 26167]
[New LWP 26373]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f78dbc43aff in __GI___poll (fds=0x7ffec6991128, nfds=1, timeout=1000) at ../sysdeps/unix/sysv/linux/poll.c:29
[Current thread is 1 (Thread 0x7f78d5e269c0 (LWP 26152))]

Thread 11 (Thread 0x7f78ceafe700 (LWP 26373)):
#0  0x00007f78dbc43aff in __GI___poll (fds=0x7f78bc0025a0, nfds=3, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007f78a95621d6 in ?? () from /lib/x86_64-linux-gnu/libpulse.so.0
#2  0x00007f78a9553841 in pa_mainloop_poll () from /lib/x86_64-linux-gnu/libpulse.so.0
#3  0x00007f78a9553ec3 in pa_mainloop_iterate () from /lib/x86_64-linux-gnu/libpulse.so.0
#4  0x00007f78a9553f70 in pa_mainloop_run () from /lib/x86_64-linux-gnu/libpulse.so.0
#5  0x00007f78a956211d in ?? () from /lib/x86_64-linux-gnu/libpulse.so.0
#6  0x00007f78a94fe72c in ?? () from /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-13.99.so
#7  0x00007f78da7dd609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#8  0x00007f78dbc50293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 10 (Thread 0x7f785adff700 (LWP 26167)):
#0  0x00007f78dbc43aff in __GI___poll (fds=0x7f784c004a30, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007f78d906936e in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f78d90694a3 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f78dc37affb in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007f78dc31f1eb in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007f78dc139a52 in QThread::exec() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007f78dc13abec in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007f78da7dd609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#8  0x00007f78dbc50293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 9 (Thread 0x7f785bffd700 (LWP 26166)):
#0  0x00007f78dbc43aff in __GI___poll (fds=0x7f7854005240, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007f78d906936e in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f78d90694a3 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f78dc37affb in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007f78dc31f1eb in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007f78dc139a52 in QThread::exec() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007f78dc13abec in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007f78da7dd609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#8  0x00007f78dbc50293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 8 (Thread 0x7f78aa534700 (LWP 26165)):
#0  futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x7f78dfdad9b0) at ../sysdeps/nptl/futex-internal.h:183
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x25fb1a0, cond=0x7f78dfdad988) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7f78dfdad988, mutex=0x25fb1a0) at pthread_cond_wait.c:638
#3  0x00007f78dbf5ce50 in std::condition_variable::wait(std::unique_lock<std::mutex>&) () from /lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007f78df33f641 in ?? () from /lib/x86_64-linux-gnu/libQt5WebKit.so.5
#5  0x00007f78df33f75f in ?? () from /lib/x86_64-linux-gnu/libQt5WebKit.so.5
#6  0x00007f78dbf62d84 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007f78da7dd609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#8  0x00007f78dbc50293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 7 (Thread 0x7f78b08fd700 (LWP 26163)):
#0  futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x23a1388) at ../sysdeps/nptl/futex-internal.h:183
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x23a1338, cond=0x23a1360) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x23a1360, mutex=0x23a1338) at pthread_cond_wait.c:638
#3  0x00007f78b6d5eb5b in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#4  0x00007f78b6d5e75b in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#5  0x00007f78da7dd609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#6  0x00007f78dbc50293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 6 (Thread 0x7f78b10fe700 (LWP 26162)):
#0  futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x23a1388) at ../sysdeps/nptl/futex-internal.h:183
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x23a1338, cond=0x23a1360) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x23a1360, mutex=0x23a1338) at pthread_cond_wait.c:638
#3  0x00007f78b6d5eb5b in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#4  0x00007f78b6d5e75b in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#5  0x00007f78da7dd609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#6  0x00007f78dbc50293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 5 (Thread 0x7f78abfff700 (LWP 26161)):
#0  futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x23a1388) at ../sysdeps/nptl/futex-internal.h:183
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x23a1338, cond=0x23a1360) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x23a1360, mutex=0x23a1338) at pthread_cond_wait.c:638
#3  0x00007f78b6d5eb5b in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#4  0x00007f78b6d5e75b in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#5  0x00007f78da7dd609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#6  0x00007f78dbc50293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 4 (Thread 0x7f78b18ff700 (LWP 26160)):
#0  futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x23a1388) at ../sysdeps/nptl/futex-internal.h:183
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x23a1338, cond=0x23a1360) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x23a1360, mutex=0x23a1338) at pthread_cond_wait.c:638
#3  0x00007f78b6d5eb5b in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#4  0x00007f78b6d5e75b in ?? () from /usr/lib/x86_64-linux-gnu/dri/iris_dri.so
#5  0x00007f78da7dd609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#6  0x00007f78dbc50293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 3 (Thread 0x7f78cffff700 (LWP 26154)):
#0  0x00007f78dbc43ad8 in __GI___poll (fds=0x7f78c8011130, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007f78d906936e in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007f78d90694a3 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007f78dc37affb in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007f78dc31f1eb in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007f78dc139a52 in QThread::exec() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007f78dc5daf4b in ?? () from /lib/x86_64-linux-gnu/libQt5DBus.so.5
#7  0x00007f78dc13abec in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007f78da7dd609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#9  0x00007f78dbc50293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7f78d54bc700 (LWP 26153)):
#0  0x00007f78dbc43aff in __GI___poll (fds=0x7f78d54bbae8, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007f78d8bb7c1a in ?? () from /lib/x86_64-linux-gnu/libxcb.so.1
#2  0x00007f78d8bb990a in xcb_wait_for_event () from /lib/x86_64-linux-gnu/libxcb.so.1
#3  0x00007f78d59c6d58 in ?? () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#4  0x00007f78dc13abec in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007f78da7dd609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#6  0x00007f78dbc50293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7f78d5e269c0 (LWP 26152)):
[KCrash Handler]
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x00007f78dbb53859 in __GI_abort () at abort.c:79
#6  0x00007f78dbf2a951 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007f78dbf3647c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#8  0x00007f78dbf364e7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#9  0x00007f78dbf367ed in __cxa_rethrow () from /lib/x86_64-linux-gnu/libstdc++.so.6
#10 0x000000000048224e in main (argc=2, argv=<optimized out>) at ./kmymoney/main.cpp:286
[Inferior 1 (process 26152) detached]
Comment 1 Martin Tlustos 2021-03-19 06:17:59 UTC
O.k., after searching for the cause of the problem I found that I had two colons the categories column in one of the entries and kmymoney obviously can't handle an empty category. My error, but kmymoney shouldn't crash, but give an appropriate warning.
Comment 2 Jack 2021-03-19 17:10:06 UTC
When importing a csv file, if a column is mapped to Category, and that column has a value of "::" in any row, an exception is thrown in kmymoney/mymoney/mymoneyfile.cpp (MyMoneyFile::addAccount line 938 in 5.1 git head, possibly different line in other branches).  I assume this is trying to create an account for the category, since one doesn't already exist.  While the exception is correct, I see two problems here.  First, the exception should be caught, otherwise you get a crash.  Second, a more helpful error message would indicate that the account in question is a Category, and not a regular Account, to give the user a better chance of finding and fixing the error in the input csv file.  (Separate questions - should it be allowed to import a transaction without a category?)
Comment 3 Thomas Baumgart 2021-03-21 11:21:47 UTC
Can you provide a sample CSV file that shows the problem and explain the settings you have performed during the CSV import in detail? This way, we shall be able to duplicate the problem. Thanks in advance.
Comment 4 Jack 2021-03-21 15:24:50 UTC
20201002,"Purchase",$190.00,"Memo"
20201003,"::",$190.00,"Memo"
20201004,"Purchase",$40.00,"Memo"

The above three line csv file caused the crash for me.  Columns mapped to date, category, amount, payee, and I imported using the "banking" profile.  I had tried earlier to use a completely blank category, but the importer tried to exclude that line by adjusting the start and end lines to import, so I switched to the "::" as mentioned in Comment #1.  I did not also try embedding the double colon within a longer string.  I was using a newly created kmy file with just the checking account, and no categories initially created.
Comment 5 Thomas Baumgart 2021-03-28 06:14:05 UTC
The problem is using the colon without a following character. The colon is treated as a separator for account hierarchies at this point and gets removed during the process. This leaves an empty name which causes the crash.
Comment 6 Thomas Baumgart 2021-03-28 06:15:12 UTC
Git commit 12ef8de0febc644707791f0a5705e29abaa38da7 by Thomas Baumgart.
Committed on 28/03/2021 at 06:14.
Pushed by tbaumgart into branch '5.1'.

Don't try to create an account without a name
FIXED-IN: 5.1.2

M  +3    -2    kmymoney/mymoney/mymoneyfile.cpp

https://invent.kde.org/office/kmymoney/commit/12ef8de0febc644707791f0a5705e29abaa38da7
Comment 7 Thomas Baumgart 2021-03-28 06:23:56 UTC
Git commit 0bee8c5200b1d4b19525796589dfc62abbe507a4 by Thomas Baumgart.
Committed on 28/03/2021 at 06:23.
Pushed by tbaumgart into branch 'master'.

Don't try to create an account without a name

(cherry picked from commit 12ef8de0febc644707791f0a5705e29abaa38da7)

M  +3    -2    kmymoney/mymoney/mymoneyfile.cpp

https://invent.kde.org/office/kmymoney/commit/0bee8c5200b1d4b19525796589dfc62abbe507a4