Fix octave backend problem with repetitive addition of function `cantor_print ()` in worksheet
ClosedPublic

Authored by sirgienko on Mar 23 2018, 9:11 PM.

Details

Summary

Octave use special script for plots, that is added for each entry with octave plot commands. Unfortunately, this command is add to entry when expressions in worksheet are saving (maybe should add virtual method toSaveString() to Cantor::Expression?). So, I have added addition check, if this command already exist in entry, to avoid the multiple addition of this command to entries each time, when worksheet save and load.

Test Plan
  1. Create worksheet and write some commands to print plots
  2. Save and load this worksheet
  3. Do 2) again few times
  4. Verify,that cantor_print() function appears no more than once in each entry.

Diff Detail

Repository
R55 Cantor
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
sirgienko created this revision.Mar 23 2018, 9:11 PM
Restricted Application added a project: KDE Edu. · View Herald TranscriptMar 23 2018, 9:11 PM
Restricted Application added a subscriber: KDE Edu. · View Herald Transcript
sirgienko requested review of this revision.Mar 23 2018, 9:11 PM
sirgienko retitled this revision from Fix problems with repetitive addition of function `cantor_print ()` in worksheet to Fix octave backend problems with repetitive addition of function `cantor_print ()` in worksheet.
sirgienko retitled this revision from Fix octave backend problems with repetitive addition of function `cantor_print ()` in worksheet to Fix octave backend problem with repetitive addition of function `cantor_print ()` in worksheet.
asemke added a comment.EditedApr 2 2018, 7:59 PM

I don't see where and when this "cantor_plot" is executed Here the debug output for me for the plot expression after i=1:2:100, w=i/10 and plot(i/10,w):

evaluating: "plot(i/10,w)"
evaluate
Executing a plot command
runExpression
wsStatusChange 0
readError
"warning: print.m: epstool binary is not available.\nSome output formats are not available.\n"
currentExpressionStatusChanged
wsStatusChange 1
readOutput
start parsing "octave:5> "
readError
finalize: ""
true true
parsePlotFile
OctaveExpression::parsePlotFile: "/tmp/c-ob-HcEJ3n.png"
settting result to a type 2 result
update Entry
new result
QSizeF(3176, 74) QSizeF(3176, 414)
currentExpressionStatusChanged
wsStatusChange 1
Entry Appended

Can you please send the output you get and maybe also attach your test file?

sirgienko added a comment.EditedApr 2 2018, 8:29 PM

I don't see where and when this "cantor_plot" is executed Here the debug output for me for the plot expression after i=1:2:100, w=i/10 and plot(i/10,w):
Can you please send the output you get and maybe also attach your test file?

Write test worksheet and run it:


Save it and reopen:

(Well, i also found, that if I save worksheet, close it (but don't close cantor) and open again, entries never end calculation and backend restart cause SEGFAULT)
(I can open saved worksheet only if I don't run octave before opening in this session)
(@asemke, could you reproduce this problem?)
What about this cantor_print() (15.12 'stable' cantor also have this problem): each time, when you save worksheet this command is added to worksheet (not more than once per cantor session)

asemke added a comment.Apr 3 2018, 7:19 AM

I don't see where and when this "cantor_plot" is executed Here the debug output for me for the plot expression after i=1:2:100, w=i/10 and plot(i/10,w):
Can you please send the output you get and maybe also attach your test file?

Write test worksheet and run it:


Save it and reopen:

Oh, sorry, I was looking for cantor_plot* and not for cantor_print. Now I've got it. Your fix makes sense. But add those contains-calls into the if-statement so we don't need to call QString::contains() twice for nothing in case m_plotPending is false. Simply use

if (m_plotPending && !cmd.contains(QLatin1String("cantor_plot")) && !cmd.contains(QLatin1String(printCommand)))

Do you want to upload a new diff with this change or should I create a commit and push it?

(Well, i also found, that if I save worksheet, close it (but don't close cantor) and open again, entries never end calculation and backend restart cause SEGFAULT)
(I can open saved worksheet only if I don't run octave before opening in this session)
(@asemke, could you reproduce this problem?)

I have similar problem(s) - after fresh start of cantor and openning a saved worksheet there is syntax highlighting, execution saved entries fails and there is a crash when doing "backend restart".

What about this cantor_print() (15.12 'stable' cantor also have this problem): each time, when you save worksheet this command is added to worksheet (not more than once per cantor session)

Let's concentrate on 18.04 now. We have two outstanding problems that need to be urgently fixed - running of the saved project and missing latex output.

sirgienko updated this revision to Diff 31198.Apr 3 2018, 7:28 AM

Upload diff

sirgienko added a comment.EditedApr 3 2018, 5:10 PM

What about this cantor_print() (15.12 'stable' cantor also have this problem): each time, when you save worksheet this command is added to worksheet (not more than once per cantor session)

Let's concentrate on 18.04 now. We have two outstanding problems that need to be urgently fixed - running of the saved project and missing latex output.

@asemke, maybe I understand, what is the problem: when we load worksheet, we login twice.

I think, that we shouldn't login twice. Do you know, why we do second login?

First login backtrace (not full):

#0  OctaveSession::login (this=0x147bf90)
    at /home/mmmm1998/Документы/Репозитории/cantor/src/backends/octave/octavesession.cpp:59
#1  0x00007fffbe00561d in Worksheet::loginToSession (this=0x8e3a00)
    at /home/mmmm1998/Документы/Репозитории/cantor/src/worksheet.cpp:89
#2  Worksheet::enableHighlighting (this=this@entry=0x8e3a00, highlight=<optimized out>)
    at /home/mmmm1998/Документы/Репозитории/cantor/src/worksheet.cpp:769
#3  0x00007fffbe0067c3 in Worksheet::load (this=this@entry=0x8e3a00, 
    device=device@entry=0x7fffffffcc90)
    at /home/mmmm1998/Документы/Репозитории/cantor/src/worksheet.cpp:1053
#4  0x00007fffbe006ea0 in Worksheet::load (this=0x8e3a00, filename=...)
    at /home/mmmm1998/Документы/Репозитории/cantor/src/worksheet.cpp:951
#5  0x00007fffbdff4f02 in CantorPart::openFile (this=0x88dee0)
    at /home/mmmm1998/Документы/Репозитории/cantor/src/cantor_part.cpp:427

Second login backtace (pay attention to value of m_loginDone)

#0  OctaveSession::login (this=0x147bf90)
    at /home/mmmm1998/Документы/Репозитории/cantor/src/backends/octave/octavesession.cpp:59
#1  0x00007fffbdffef8e in Worksheet::loginToSession (this=0x8e3a00)
    at /home/mmmm1998/Документы/Репозитории/cantor/src/worksheet.cpp:89
#2  0x00007fffbe038ed0 in Worksheet::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, 
    _id=<optimized out>, _a=<optimized out>)
    at /home/mmmm1998/Документы/Репозитории/cantor/build/src/moc_worksheet.cpp:531
#3  0x00007ffff4c39211 in QObject::event(QEvent*) ()
   from /home/mmmm1998/Qt/5.8/gcc_64/lib/libQt5Core.so.5
#4  0x00007ffff5c9cf4b in QGraphicsScene::event(QEvent*) ()
   from /home/mmmm1998/Qt/5.8/gcc_64/lib/libQt5Widgets.so.5
#5  0x00007ffff59a9dcc in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from /home/mmmm1998/Qt/5.8/gcc_64/lib/libQt5Widgets.so.5
#6  0x00007ffff59b1236 in QApplication::notify(QObject*, QEvent*) ()
   from /home/mmmm1998/Qt/5.8/gcc_64/lib/libQt5Widgets.so.5
#7  0x00007ffff4c0f458 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
   from /home/mmmm1998/Qt/5.8/gcc_64/lib/libQt5Core.so.5
(More stack frames follow...)
(gdb) frame 1
#1  0x00007fffbdffef8e in Worksheet::loginToSession (this=0x8e3a00)
    at /home/mmmm1998/Документы/Репозитории/cantor/src/worksheet.cpp:89
89	    m_session->login();
(gdb) print m_loginDone
$1 = true

Full cantor output log:


Full gdb log:

This revision was not accepted when it landed; it landed in state Needs Review.Apr 3 2018, 8:15 PM
This revision was automatically updated to reflect the committed changes.
asemke added a comment.Apr 5 2018, 8:28 AM

Write test worksheet and run it:


Save it and reopen:

@sirgienko From your screenshot I see that the plot image files are not loaded for you neither. I pushed a fix now in d4585fca577a2732f9f4469766ae6a4b90a1bc58. Does it also fix this problem for you?

sirgienko added a comment.EditedApr 5 2018, 10:47 AM

Write test worksheet and run it:


Save it and reopen:

@sirgienko From your screenshot I see that the plot image files are not loaded for you neither. I pushed a fix now in d4585fca577a2732f9f4469766ae6a4b90a1bc58. Does it also fix this problem for you?

Yes, now if I open worksheet i also see plots.

@asemke, I also found problem with c3aa8b3e18d4c7be8c094a5acbd4864b09b5eb02: If we choose octave backend, but don't write anything (so login don't called) and trying to open saved octave worksheet, we get segfault, because in this case we never call OctaveSession::login (i have checked it with gdb).

asemke added a comment.Apr 5 2018, 2:42 PM

@asemke, I also found problem with c3aa8b3e18d4c7be8c094a5acbd4864b09b5eb02: If we choose octave backend, but don't write anything (so login don't called) and trying to open saved octave worksheet, we get segfault, because in this case we never call OctaveSession::login (i have checked it with gdb).

This is fixed now with 2ca024892335728f48d7aa3dfc22032b39b10819. Thanks for reporting this.