Bug 442845 - Task scheduler: crashes if user discards printing crontab
Summary: Task scheduler: crashes if user discards printing crontab
Status: RESOLVED FIXED
Alias: None
Product: kcron
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Gary Meyer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-23 14:56 UTC by Oleg Solovyov
Modified: 2021-09-27 15:03 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Solovyov 2021-09-23 14:56:03 UTC
STEPS TO REPRODUCE
1. Open systemsettings -> Startup and Shutdown -> Task scheduler
1.1 Make a task if table is empty
2. Click "Print..."
3. Click "Cancel"
4. Quit "Task Scheduler"

OBSERVED RESULT
Crash

EXPECTED RESULT
Another KCM is opened

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 5.11.0-generic36
KDE Plasma Version: 5.23.80
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.3
KDE Neon Unstable Edition

ADDITIONAL INFORMATION
After step 2, KCM area became blank

BACKTRACE
https://pastebin.com/rZvaqGLM
Comment 1 Oleg Solovyov 2021-09-23 15:11:39 UTC
That's what happens when I press "Cancel" on print dialog:

#0  CrontabWidget::~CrontabWidget (this=0x555555fb59f0, __in_chrg=<optimized out>) at ./src/crontabWidget.cpp:75
#1  0x00007ffff68df39e in QObjectPrivate::deleteChildren (this=this@entry=0x555555e78bd0) at kernel/qobject.cpp:2104
#2  0x00007ffff75076a6 in QWidget::~QWidget (this=0x55555567e550, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1522
#3  0x00007ffff76828bd in QStackedWidget::~QStackedWidget (this=0x55555567e550, __in_chrg=<optimized out>)
    at widgets/qstackedwidget.cpp:145
#4  0x00007ffff68df39e in QObjectPrivate::deleteChildren (this=this@entry=0x555557c267b0) at kernel/qobject.cpp:2104
#5  0x00007ffff75076a6 in QWidget::~QWidget (this=0x555555ecbf60, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1522
#6  0x00007ffff76a5aad in QTabWidget::~QTabWidget (this=0x555555ecbf60, __in_chrg=<optimized out>)
    at widgets/qtabwidget.cpp:372
#7  0x00007ffff68df39e in QObjectPrivate::deleteChildren (this=this@entry=0x55555599d790) at kernel/qobject.cpp:2104
#8  0x00007ffff75076a6 in QWidget::~QWidget (this=0x5555560e9b50, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1522
#9  0x00007ffff750789d in QWidget::~QWidget (this=0x5555560e9b50, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1400
#10 0x00007ffff68df39e in QObjectPrivate::deleteChildren (this=this@entry=0x55555812b790) at kernel/qobject.cpp:2104
#11 0x00007ffff75076a6 in QWidget::~QWidget (this=0x555557c99590, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1522
#12 0x00007ffff50c77ad in QPrintDialog::~QPrintDialog() () from /lib/x86_64-linux-gnu/libQt5PrintSupport.so.5
#13 0x00007fffabfbf967 in CrontabPrinter::start (this=this@entry=0x7fffffffcc10) at ./src/crontabPrinter.cpp:64
#14 0x00007fffabfbb247 in CrontabWidget::print (this=<optimized out>) at ./src/crontabWidget.cpp:368

I don't understand why CrontabWidget d-tor is called
Comment 2 Tom Max 2021-09-24 13:43:14 UTC
> I don't understand why CrontabWidget d-tor is called

here a CrontabPrinter is create, and a CrontabWidget is passed to the c-tor

void CrontabWidget::print()
{
    CrontabPrinter printer(this);

and named mCrontabWidget

CrontabPrinter::CrontabPrinter(CrontabWidget *crontabWidget)
    : mCrontabWidget(crontabWidget)

then (crontabPrinter.cpp:60)
  printDialog->setOptionTabs(QList<QWidget *>() << mCrontabWidget);

probably when the printDialog d-tor is called (crontabPrinter.cpp:64),
mCrontabWidget d-tor is called
Comment 3 Oleg Solovyov 2021-09-24 15:32:02 UTC
(In reply to Tommaso Massimi from comment #2)
> then (crontabPrinter.cpp:60)
>   printDialog->setOptionTabs(QList<QWidget *>() << mCrontabWidget);

Maybe we can remove this line?
Comment 4 Bug Janitor Service 2021-09-24 15:41:19 UTC
A possibly relevant merge request was started @ https://invent.kde.org/system/kcron/-/merge_requests/1
Comment 5 Oleg Solovyov 2021-09-27 15:03:22 UTC
Git commit 884a2d1c98ac1f633d63eb8e58a91f26544d9482 by Oleg Solovyov.
Committed on 24/09/2021 at 15:36.
Pushed by mlaurent into branch 'master'.

Don't set option tabs

QPrintDialog deletes all tabs upon destructing, which causes double-free
error.

M  +0    -1    src/crontabPrinter.cpp

https://invent.kde.org/system/kcron/commit/884a2d1c98ac1f633d63eb8e58a91f26544d9482