Dear Maintainer, hello Kinky Nekoboi,
just tried to reproduce this issue and there is really a crash.

In a minimal buster amd64 qemu VM,
with installed cantor and cantor-backend-sage packages.

Then follow these steps:
- start cantor
- select Sage backend
- enter in the field below the "Session 1" tab marked with ">>>":
    plot(cos, (-5,5))
- press "Evaluate Worksheet"


----

The actual crash happens in cantor_sagebackend.so.
There the version of sagemath is tried to be retrieved by
executing "/usr/bin/sage -v".

Unfortunately this outputs just an error message, therefore
is nothing read from stdinput. In the console the output
"found version:  ()" from line 472 is visible.
This empty line is processed then by a regular expression
and that is expected to return results on index 1 and 2.


    benutzer@debian:~$ /usr/bin/sage -v
    /usr/bin/sage: line 16: /src/bin/sage-version.sh: No such file or directory


    (gdb) list sagesession.cpp:462,500
    462     bool SageSession::updateSageVersion()
    463     {
    464         QProcess get_sage_version;
    465         
get_sage_version.setProgram(SageSettings::self()->path().toLocalFile());
    466         
get_sage_version.setArguments(QStringList()<<QLatin1String("-v"));
    467         get_sage_version.start();
    468         get_sage_version.waitForFinished(-1);
    469         QString versionString = 
QString::fromLocal8Bit(get_sage_version.readLine());
    470         QRegularExpression versionExp(QLatin1String("(\\d+)\\.(\\d+)"));
    471         QRegularExpressionMatch version = 
versionExp.match(versionString);
    472         qDebug()<<"found version: " << version.capturedTexts();
    473         if(version.isValid())
    474         {
    475             int major=version.capturedTexts()[1].toInt();
    476             int minor=version.capturedTexts()[2].toInt();

----

The file /usr/bin/sage is a bash script and retrieves the actual version
by sourcing a file sage-version.sh.
Unfortunately seems neither SAGE_SCRIPTS_DIR nor SAGE_ROOT set.

    ...
    sage_version() {
        if [ -f "$SAGE_SCRIPTS_DIR/sage-version.sh" ]; then
            . "$SAGE_SCRIPTS_DIR/sage-version.sh"
        else
            . "$SAGE_ROOT/src/bin/sage-version.sh"
        fi
    ...


Later in that file a file sage-env would be sourced, but with the parameter "-v"
this lines are never reached:

    ...
    if [ "$1" = '-v' -o "$1" = '-version' -o "$1" = '--version' ]; then
            sage_version -v
            exit 0
    fi
    ...
    if [ "\"$0\"" = "\"/usr/bin/sage\"" ]; then
        . "/usr/share/sagemath/bin/sage-env" >&2
    else
        . "$0-env" >&2
    fi
    ...

----

Attached patch moves the sourcing of sage-env above the call to sage_version.
With that applied cantor successfully can draw and show that plot command.
But I really cannot estimate what else that could break elsewhere.

----

I think both issues deserve to be tracked separately:
- cantor_sagebackend.so should be more robust against the output of 
/usr/bin/sage
- /usr/bin/sage should report its version


Kind regards,
Bernhard


(gdb) bt
#0  0x00007f97c94617ac in QString::toIntegral_helper<int> (base=10, ok=0x0, 
len=<error reading variable: Cannot access memory at address 0x35>, data=<error 
reading variable: Cannot access memory at address 0x41>) at 
../../include/QtCore/../../src/corelib/tools/qstring.h:895
#1  QString::toInt (this=<optimized out>, ok=ok@entry=0x0, base=base@entry=10) 
at tools/qstring.cpp:7078
#2  0x00007f97c005007d in SageSession::updateSageVersion() () at 
/usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:115
#3  0x00007f97c00503f1 in SageSession::login() () at 
./src/backends/sage/sagesession.cpp:119
#4  0x00007f97b0042621 in Worksheet::loginToSession 
(this=this@entry=0x55b0052087f0) at ./src/worksheet.cpp:93
#5  0x00007f97b0042c10 in Worksheet::evaluate() () at ./src/worksheet.cpp:457
#6  0x00007f97b00387d2 in CantorPart::evaluateOrInterrupt() () at 
./src/cantor_part.cpp:529
#7  0x00007f97b00767ed in CantorPart::qt_static_metacall (_o=<optimized out>, 
_id=<optimized out>, _a=<optimized out>, _c=<optimized out>) at 
./obj-x86_64-linux-gnu/src/cantorpart_autogen/EWIEGA46WW/moc_cantor_part.cpp:207
#8  0x00007f97c95bb28b in QMetaObject::activate(QObject*, int, int, void**) () 
at kernel/qobject.cpp:3771
#9  0x00007f97c95bb8a7 in QMetaObject::activate 
(sender=sender@entry=0x55b00525e970, m=m@entry=0x7f97ca3d1840 
<QAction::staticMetaObject>, local_signal_index=local_signal_index@entry=1, 
argv=argv@entry=0x7ffdca3ab9d0) at kernel/qobject.cpp:3633
#10 0x00007f97c9f01ee2 in QAction::triggered (this=this@entry=0x55b00525e970, 
_t1=<optimized out>) at .moc/moc_qaction.cpp:376
#11 0x00007f97c9f044f0 in QAction::activate (this=0x55b00525e970, 
event=<optimized out>) at kernel/qaction.cpp:1166
#12 0x00007f97c9fefc8d in QAbstractButtonPrivate::click (this=0x55b0053538b0) 
at widgets/qabstractbutton.cpp:397
#13 0x00007f97c9fefec5 in QAbstractButton::mouseReleaseEvent 
(this=0x55b0053533a0, e=0x7ffdca3abea0) at widgets/qabstractbutton.cpp:1011
#14 0x00007f97ca0d9c0a in QToolButton::mouseReleaseEvent (this=<optimized out>, 
e=<optimized out>) at widgets/qtoolbutton.cpp:622
#15 0x00007f97c9f467c8 in QWidget::event (this=0x55b0053533a0, 
event=0x7ffdca3abea0) at kernel/qwidget.cpp:8925
#16 0x00007f97c9ff1103 in QAbstractButton::event 
(this=this@entry=0x55b0053533a0, e=e@entry=0x7ffdca3abea0) at 
widgets/qabstractbutton.cpp:968
#17 0x00007f97ca0d9cb3 in QToolButton::event (this=0x55b0053533a0, 
event=0x7ffdca3abea0) at widgets/qtoolbutton.cpp:985
#18 0x00007f97c9f08491 in QApplicationPrivate::notify_helper 
(this=this@entry=0x55b004f5e380, receiver=receiver@entry=0x55b0053533a0, 
e=e@entry=0x7ffdca3abea0) at kernel/qapplication.cpp:3727
#19 0x00007f97c9f0fd18 in QApplication::notify(QObject*, QEvent*) () at 
kernel/qapplication.cpp:3203
#20 0x00007f97c9592039 in QCoreApplication::notifyInternal2(QObject*, QEvent*) 
() at 
../../include/QtCore/5.11.2/QtCore/private/../../../../../src/corelib/thread/qthread_p.h:307
#21 0x00007f97c9f0f019 in QCoreApplication::sendEvent (event=<optimized out>, 
receiver=<optimized out>) at 
../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:234
#22 QApplicationPrivate::sendMouseEvent 
(receiver=receiver@entry=0x55b0053533a0, event=event@entry=0x7ffdca3abea0, 
alienWidget=alienWidget@entry=0x55b0053533a0, nativeWidget=0x55b004fa5610, 
buttonDown=buttonDown@entry=0x7f97ca400870 <qt_button_down>, 
lastMouseReceiver=..., spontaneous=true) at kernel/qapplication.cpp:2695
#23 0x00007f97c9f61304 in QWidgetWindow::handleMouseEvent(QMouseEvent*) () at 
/usr/include/c++/8/bits/atomic_base.h:390
#24 0x00007f97c9f63e8e in QWidgetWindow::event (this=0x55b005079450, 
event=0x7ffdca3ac2a0) at kernel/qwidgetwindow.cpp:281
#25 0x00007f97c9f08491 in QApplicationPrivate::notify_helper 
(this=this@entry=0x55b004f5e380, receiver=receiver@entry=0x55b005079450, 
e=e@entry=0x7ffdca3ac2a0) at kernel/qapplication.cpp:3727
#26 0x00007f97c9f0fad0 in QApplication::notify(QObject*, QEvent*) () at 
kernel/qapplication.cpp:3486
#27 0x00007f97c9592039 in QCoreApplication::notifyInternal2(QObject*, QEvent*) 
() at 
../../include/QtCore/5.11.2/QtCore/private/../../../../../src/corelib/thread/qthread_p.h:307
#28 0x00007f97c993bb2b in QCoreApplication::sendSpontaneousEvent 
(event=0x7ffdca3ac2a0, receiver=0x55b005079450) at 
../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:237
#29 QGuiApplicationPrivate::processMouseEvent (e=0x55b0051a06f0) at 
kernel/qguiapplication.cpp:2081
#30 0x00007f97c993da25 in QGuiApplicationPrivate::processWindowSystemEvent 
(e=e@entry=0x55b0051a06f0) at kernel/qguiapplication.cpp:1816
#31 0x00007f97c9917d8b in QWindowSystemInterface::sendWindowSystemEvents 
(flags=...) at kernel/qwindowsysteminterface.cpp:1032
#32 0x00007f97c3c5485b in QPAEventDispatcherGlib::processEvents 
(this=0x55b004f9dda0, flags=...) at qeventdispatcher_glib.cpp:70
#33 0x00007f97c9590d0b in 
QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at 
../../include/QtCore/../../src/corelib/global/qflags.h:140
#34 0x00007f97c9598e82 in QCoreApplication::exec() () at 
../../include/QtCore/../../src/corelib/global/qflags.h:120
#35 0x000055b004050d17 in main () at ./src/main.cpp:147
#36 0x00007f97c8fefb17 in __libc_start_main (main=0x55b004050040 <main>, 
argc=1, argv=0x7ffdca3ac7e8, init=<optimized out>, fini=<optimized out>, 
rtld_fini=<optimized out>, stack_end=0x7ffdca3ac7d8) at ../csu/libc-start.c:310
#37 0x000055b0040511ca in _start () at ./src/main.cpp:130


apt install xserver-xorg lightdm openbox xterm mc tmux systemd-coredump 
sagemath cantor-backend-sage

systemctl start lightdm


export LANG=C
export DISPLAY=:0
cantor

# select sage as backend

#enter
plot(cos, (-5,5))

# "Evaluate Worksheet"


###########

benutzer@debian:~$ export LANG=C
benutzer@debian:~$ export DISPLAY=:0
benutzer@debian:~$ cantor
dir:  "/usr/lib/x86_64-linux-gnu/qt5/plugins/cantor/backends"
Creating NullBackend
Creating SageBackend
dir:  "/usr/bin/cantor/backends"
Created a CantorPart
Backend  "Sage"  offers extensions:  ("HistoryExtension", "ScriptExtension", 
"CASExtension", "CalculusExtension", "LinearAlgebraExtension", "PlotExtension", 
"PackagingExtension")
Spawning a new Sage session
new worksheetaccess interface
loading assistants...
dir:  "/usr/lib/x86_64-linux-gnu/qt5/plugins/cantor/assistants"
plugin  "AdvancedPlot"  requires  ("AdvancedPlotExtension")
plugin  "AdvancedPlot"  is   not   supported by  "Sage"
plugin  "Create Matrix"  requires  ("LinearAlgebraExtension")
plugin  "Create Matrix"  is    supported by  "Sage"
plugin  "Differentiate"  requires  ("CalculusExtension")
plugin  "Differentiate"  is    supported by  "Sage"
plugin  "Eigenvalues"  requires  ("LinearAlgebraExtension", "HistoryExtension")
plugin  "Eigenvalues"  is    supported by  "Sage"
plugin  "Eigenvectors"  requires  ("LinearAlgebraExtension", "HistoryExtension")
plugin  "Eigenvectors"  is    supported by  "Sage"
plugin  "Import Package"  requires  ("PackagingExtension")
plugin  "Import Package"  is    supported by  "Sage"
plugin  "Integrate"  requires  ("CalculusExtension")
plugin  "Integrate"  is    supported by  "Sage"
plugin  "Invert Matrix"  requires  ("LinearAlgebraExtension", 
"HistoryExtension")
plugin  "Invert Matrix"  is    supported by  "Sage"
plugin  "Plot2d"  requires  ("PlotExtension")
plugin  "Plot2d"  is    supported by  "Sage"
plugin  "Plot3d"  requires  ("PlotExtension")
plugin  "Plot3d"  is    supported by  "Sage"
plugin  "QalculatePlot"  requires  ("QalculatePlotExtension")
plugin  "QalculatePlot"  is   not   supported by  "Sage"
plugin  "RunScript"  requires  ("ScriptExtension")
plugin  "RunScript"  is    supported by  "Sage"
plugin  "Solve"  requires  ("CASExtension")
plugin  "Solve"  is    supported by  "Sage"
dir:  "/usr/bin/cantor/assistants"
loading panel plugins for session of type  "Sage"
dir:  "/usr/lib/x86_64-linux-gnu/qt5/plugins/cantor/panels"
plugin  "Help"  requires  ("")
Requesting capabilities of SageSession
plugin  "Help"  is    supported
plugin  "Variable Manager"  requires  ("VariableManagementExtension")
plugin  "Variable Manager"  is   not   supported
dir:  "/usr/bin/cantor/panels"
Requesting capabilities of SageSession
Requesting capabilities of SageSession
Entry Appended
adding panel for  "Help"
No text-to-speech plug-ins were found.
Entry Appended
evalorinterrupt
evaluate worksheet
login
found version:  ()
Segmentation fault (core dumped)


[  352.100094] cantor[910]: segfault at 35 ip 00007f97c94617ac sp 
00007ffdca3ab5c0 error 4 in libQt5Core.so.5.11.2[7f97c93a6000+2a3000]
[  352.100102] Code: 3f 48 89 f0 89 d1 48 89 c2 8b 77 04 48 03 7f 10 e9 69 ff 
ff ff 90 0f 1f 84 00 00 00 00 00 53 48 8b 3f 48 89 f3 89 d1 48 89 da <8b> 77 04 
48 03 7f 10 e8 e8 fe ff ff 48 63 c8 48 39 c8 


root@debian:~# coredumpctl list
TIME                            PID   UID   GID SIG COREFILE  EXE
Fri 2018-11-23 19:19:41 CET     910  1000  1000  11 present   /usr/bin/cantor
root@debian:~# coredumpctl gdb 910
           PID: 910 (cantor)
           UID: 1000 (benutzer)
           GID: 1000 (benutzer)
        Signal: 11 (SEGV)
     Timestamp: Fri 2018-11-23 19:19:40 CET (2min 44s ago)
  Command Line: cantor
    Executable: /usr/bin/cantor
 Control Group: /user.slice/user-1000.slice/session-4.scope
          Unit: session-4.scope
         Slice: user-1000.slice
       Session: 4
     Owner UID: 1000 (benutzer)
       Boot ID: 7ad84941b8e04c339b41966e8698e886
    Machine ID: 32f43b50ac8c4b21941bc0b02f8e7811
      Hostname: debian
       Storage: 
/var/lib/systemd/coredump/core.cantor.1000.7ad84941b8e04c339b41966e8698e886.910.1542997180000000.lz4
       Message: Process 910 (cantor) of user 1000 dumped core.
                
                Stack trace of thread 910:
                #0  0x00007f97c94617ac _ZNK7QString5toIntEPbi (libQt5Core.so.5)
                #1  0x00007f97c005007d n/a (cantor_sagebackend.so)
                #2  0x00007f97c00503f1 n/a (cantor_sagebackend.so)
                #3  0x00007f97b0042621 n/a (libcantorpart.so)
                #4  0x00007f97b0042c10 n/a (libcantorpart.so)
                #5  0x00007f97b00387d2 n/a (libcantorpart.so)
                #6  0x00007f97b00767ed n/a (libcantorpart.so)
                #7  0x00007f97c95bb28b _ZN11QMetaObject8activateEP7QObjectiiPPv 
(libQt5Core.so.5)
                #8  0x00007f97c9f01ee2 _ZN7QAction9triggeredEb 
(libQt5Widgets.so.5)
                #9  0x00007f97c9f044f0 _ZN7QAction8activateENS_11ActionEventE 
(libQt5Widgets.so.5)
                #10 0x00007f97c9fefc8d n/a (libQt5Widgets.so.5)
                #11 0x00007f97c9fefec5 
_ZN15QAbstractButton17mouseReleaseEventEP11QMouseEvent (libQt5Widgets.so.5)
                #12 0x00007f97ca0d9c0a 
_ZN11QToolButton17mouseReleaseEventEP11QMouseEvent (libQt5Widgets.so.5)
                #13 0x00007f97c9f467c8 _ZN7QWidget5eventEP6QEvent 
(libQt5Widgets.so.5)
                #14 0x00007f97ca0d9cb3 _ZN11QToolButton5eventEP6QEvent 
(libQt5Widgets.so.5)
                #15 0x00007f97c9f08491 
_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent (libQt5Widgets.so.5)
                #16 0x00007f97c9f0fd18 
_ZN12QApplication6notifyEP7QObjectP6QEvent (libQt5Widgets.so.5)
                #17 0x00007f97c9592039 
_ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent (libQt5Core.so.5)
                #18 0x00007f97c9f0f019 
_ZN19QApplicationPrivate14sendMouseEventEP7QWidgetP11QMouseEventS1_S1_PS1_R8QPointerIS0_Eb
 (libQt5Widgets.so.5)
                #19 0x00007f97c9f61304 n/a (libQt5Widgets.so.5)
                #20 0x00007f97c9f63e8e n/a (libQt5Widgets.so.5)
                #21 0x00007f97c9f08491 
_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent (libQt5Widgets.so.5)
                #22 0x00007f97c9f0fad0 
_ZN12QApplication6notifyEP7QObjectP6QEvent (libQt5Widgets.so.5)
                #23 0x00007f97c9592039 
_ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent (libQt5Core.so.5)
                #24 0x00007f97c993bb2b 
_ZN22QGuiApplicationPrivate17processMouseEventEPN29QWindowSystemInterfacePrivate10MouseEventE
 (libQt5Gui.so.5)
                #25 0x00007f97c993da25 
_ZN22QGuiApplicationPrivate24processWindowSystemEventEPN29QWindowSystemInterfacePrivate17WindowSystemEventE
 (libQt5Gui.so.5)
                #26 0x00007f97c9917d8b 
_ZN22QWindowSystemInterface22sendWindowSystemEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE
 (libQt5Gui.so.5)
                #27 0x00007f97c3c5485b n/a (libQt5XcbQpa.so.5)
                #28 0x00007f97c9590d0b 
_ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE (libQt5Core.so.5)
                #29 0x00007f97c9598e82 _ZN16QCoreApplication4execEv 
(libQt5Core.so.5)
                #30 0x000055b004050d17 n/a (cantor)
                #31 0x00007f97c8fefb17 __libc_start_main (libc.so.6)
                #32 0x000055b0040511ca _start (cantor)
                
                Stack trace of thread 911:
                #0  0x00007f97c90ba739 __GI___poll (libc.so.6)
                #1  0x00007f97c72bfcf7 n/a (libxcb.so.1)
                #2  0x00007f97c72c191a xcb_wait_for_event (libxcb.so.1)
                #3  0x00007f97c3bc1519 n/a (libQt5XcbQpa.so.5)
                #4  0x00007f97c93e9c97 n/a (libQt5Core.so.5)
                #5  0x00007f97c8252f2a start_thread (libpthread.so.0)
                #6  0x00007f97c90c4edf __clone (libc.so.6)
                
                Stack trace of thread 915:
                #0  0x00007f97c8258e6c futex_wait_cancelable (libpthread.so.0)
                #1  0x00007f97bbac248b n/a (swrast_dri.so)
                #2  0x00007f97bbac23e7 n/a (swrast_dri.so)
                #3  0x00007f97c8252f2a start_thread (libpthread.so.0)
                #4  0x00007f97c90c4edf __clone (libc.so.6)
                
                Stack trace of thread 917:
                #0  0x00007f97c8258e6c futex_wait_cancelable (libpthread.so.0)
                #1  0x00007f97bbac248b n/a (swrast_dri.so)
                #2  0x00007f97bbac23e7 n/a (swrast_dri.so)
                #3  0x00007f97c8252f2a start_thread (libpthread.so.0)
                #4  0x00007f97c90c4edf __clone (libc.so.6)
                
                Stack trace of thread 916:
                #0  0x00007f97c8258e6c futex_wait_cancelable (libpthread.so.0)
                #1  0x00007f97bbac248b n/a (swrast_dri.so)
                #2  0x00007f97bbac23e7 n/a (swrast_dri.so)
                #3  0x00007f97c8252f2a start_thread (libpthread.so.0)
                #4  0x00007f97c90c4edf __clone (libc.so.6)
                
                Stack trace of thread 920:
                #0  0x00007f97c8258e6c futex_wait_cancelable (libpthread.so.0)
                #1  0x00007f97bbac248b n/a (swrast_dri.so)
                #2  0x00007f97bbac23e7 n/a (swrast_dri.so)
                #3  0x00007f97c8252f2a start_thread (libpthread.so.0)
                #4  0x00007f97c90c4edf __clone (libc.so.6)
                
                Stack trace of thread 918:
                #0  0x00007f97c8258e6c futex_wait_cancelable (libpthread.so.0)
                #1  0x00007f97bbac248b n/a (swrast_dri.so)
                #2  0x00007f97bbac23e7 n/a (swrast_dri.so)
                #3  0x00007f97c8252f2a start_thread (libpthread.so.0)
                #4  0x00007f97c90c4edf __clone (libc.so.6)
                
                Stack trace of thread 914:
                #0  0x00007f97c8258e6c futex_wait_cancelable (libpthread.so.0)
                #1  0x00007f97bbac248b n/a (swrast_dri.so)
                #2  0x00007f97bbac23e7 n/a (swrast_dri.so)
                #3  0x00007f97c8252f2a start_thread (libpthread.so.0)
                #4  0x00007f97c90c4edf __clone (libc.so.6)
                
                Stack trace of thread 913:
                #0  0x00007f97c8258e6c futex_wait_cancelable (libpthread.so.0)
                #1  0x00007f97bbac248b n/a (swrast_dri.so)
                #2  0x00007f97bbac23e7 n/a (swrast_dri.so)
                #3  0x00007f97c8252f2a start_thread (libpthread.so.0)
                #4  0x00007f97c90c4edf __clone (libc.so.6)
                
                Stack trace of thread 919:
                #0  0x00007f97c8258e6c futex_wait_cancelable (libpthread.so.0)
                #1  0x00007f97bbac248b n/a (swrast_dri.so)
                #2  0x00007f97bbac23e7 n/a (swrast_dri.so)
                #3  0x00007f97c8252f2a start_thread (libpthread.so.0)
                #4  0x00007f97c90c4edf __clone (libc.so.6)
                
                Stack trace of thread 912:
                #0  0x00007f97c90ba739 __GI___poll (libc.so.6)
                #1  0x00007f97c732ae46 n/a (libglib-2.0.so.0)
                #2  0x00007f97c732af6c g_main_context_iteration 
(libglib-2.0.so.0)
                #3  0x00007f97c95e3d13 
_ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE
 (libQt5Core.so.5)
                #4  0x00007f97c9590d0b 
_ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE (libQt5Core.so.5)
                #5  0x00007f97c93e00c6 _ZN7QThread4execEv (libQt5Core.so.5)
                #6  0x00007f97c850a545 n/a (libQt5DBus.so.5)
                #7  0x00007f97c93e9c97 n/a (libQt5Core.so.5)
                #8  0x00007f97c8252f2a start_thread (libpthread.so.0)
                #9  0x00007f97c90c4edf __clone (libc.so.6)

GNU gdb (Debian 8.1-4+b1) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/cantor...(no debugging symbols found)...done.
[New LWP 910]
[New LWP 911]
[New LWP 915]
[New LWP 917]
[New LWP 916]
[New LWP 920]
[New LWP 918]
[New LWP 914]
[New LWP 913]
[New LWP 919]
[New LWP 912]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `cantor'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f97c94617ac in QString::toInt(bool*, int) const () from 
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5
[Current thread is 1 (Thread 0x7f97c3d0c800 (LWP 910))]
(gdb) set width 0
(gdb) set pagination off
(gdb) bt
#0  0x00007f97c94617ac in QString::toInt(bool*, int) const () from 
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#1  0x00007f97c005007d in ?? () from 
/usr/lib/x86_64-linux-gnu/qt5/plugins/cantor/backends/cantor_sagebackend.so
#2  0x00007f97c00503f1 in ?? () from 
/usr/lib/x86_64-linux-gnu/qt5/plugins/cantor/backends/cantor_sagebackend.so
#3  0x00007f97b0042621 in ?? () from 
/usr/lib/x86_64-linux-gnu/qt5/plugins/libcantorpart.so
#4  0x00007f97b0042c10 in ?? () from 
/usr/lib/x86_64-linux-gnu/qt5/plugins/libcantorpart.so
#5  0x00007f97b00387d2 in ?? () from 
/usr/lib/x86_64-linux-gnu/qt5/plugins/libcantorpart.so
#6  0x00007f97b00767ed in ?? () from 
/usr/lib/x86_64-linux-gnu/qt5/plugins/libcantorpart.so
#7  0x00007f97c95bb28b in QMetaObject::activate(QObject*, int, int, void**) () 
from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007f97c9f01ee2 in QAction::triggered(bool) () from 
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#9  0x00007f97c9f044f0 in QAction::activate(QAction::ActionEvent) () from 
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#10 0x00007f97c9fefc8d in ?? () from 
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#11 0x00007f97c9fefec5 in QAbstractButton::mouseReleaseEvent(QMouseEvent*) () 
from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#12 0x00007f97ca0d9c0a in QToolButton::mouseReleaseEvent(QMouseEvent*) () from 
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x00007f97c9f467c8 in QWidget::event(QEvent*) () from 
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00007f97ca0d9cb3 in QToolButton::event(QEvent*) () from 
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x00007f97c9f08491 in QApplicationPrivate::notify_helper(QObject*, QEvent*) 
() from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#16 0x00007f97c9f0fd18 in QApplication::notify(QObject*, QEvent*) () from 
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007f97c9592039 in QCoreApplication::notifyInternal2(QObject*, QEvent*) 
() from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#18 0x00007f97c9f0f019 in QApplicationPrivate::sendMouseEvent(QWidget*, 
QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) () from 
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007f97c9f61304 in ?? () from 
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007f97c9f63e8e in ?? () from 
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#21 0x00007f97c9f08491 in QApplicationPrivate::notify_helper(QObject*, QEvent*) 
() from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#22 0x00007f97c9f0fad0 in QApplication::notify(QObject*, QEvent*) () from 
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#23 0x00007f97c9592039 in QCoreApplication::notifyInternal2(QObject*, QEvent*) 
() from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#24 0x00007f97c993bb2b in 
QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*)
 () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#25 0x00007f97c993da25 in 
QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*)
 () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#26 0x00007f97c9917d8b in 
QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)
 () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#27 0x00007f97c3c5485b in ?? () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#28 0x00007f97c9590d0b in 
QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from 
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#29 0x00007f97c9598e82 in QCoreApplication::exec() () from 
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#30 0x000055b004050d17 in ?? ()
#31 0x00007f97c8fefb17 in __libc_start_main (main=0x55b004050040, argc=1, 
argv=0x7ffdca3ac7e8, init=<optimized out>, fini=<optimized out>, 
rtld_fini=<optimized out>, stack_end=0x7ffdca3ac7d8) at ../csu/libc-start.c:310
#32 0x000055b0040511ca in _start ()



apt install xserver-xorg lightdm openbox xterm mc tmux systemd-coredump gdb 
sagemath cantor-backend-sage sagemath-dbgsym cantor-backend-sage-dbgsym 
libqt5core5a-dbgsym libqt5gui5-dbgsym libqt5widgets5-dbgsym cantor-dbgsym



(gdb) bt
#0  0x00007f97c94617ac in QString::toIntegral_helper<int> (base=10, ok=0x0, 
len=<error reading variable: Cannot access memory at address 0x35>, data=<error 
reading variable: Cannot access memory at address 0x41>) at 
../../include/QtCore/../../src/corelib/tools/qstring.h:895
#1  QString::toInt (this=<optimized out>, ok=ok@entry=0x0, base=base@entry=10) 
at tools/qstring.cpp:7078
#2  0x00007f97c005007d in SageSession::updateSageVersion() () at 
/usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:115
#3  0x00007f97c00503f1 in SageSession::login() () at 
./src/backends/sage/sagesession.cpp:119
#4  0x00007f97b0042621 in Worksheet::loginToSession 
(this=this@entry=0x55b0052087f0) at ./src/worksheet.cpp:93
#5  0x00007f97b0042c10 in Worksheet::evaluate() () at ./src/worksheet.cpp:457
#6  0x00007f97b00387d2 in CantorPart::evaluateOrInterrupt() () at 
./src/cantor_part.cpp:529
#7  0x00007f97b00767ed in CantorPart::qt_static_metacall (_o=<optimized out>, 
_id=<optimized out>, _a=<optimized out>, _c=<optimized out>) at 
./obj-x86_64-linux-gnu/src/cantorpart_autogen/EWIEGA46WW/moc_cantor_part.cpp:207
#8  0x00007f97c95bb28b in QMetaObject::activate(QObject*, int, int, void**) () 
at kernel/qobject.cpp:3771
#9  0x00007f97c95bb8a7 in QMetaObject::activate 
(sender=sender@entry=0x55b00525e970, m=m@entry=0x7f97ca3d1840 
<QAction::staticMetaObject>, local_signal_index=local_signal_index@entry=1, 
argv=argv@entry=0x7ffdca3ab9d0) at kernel/qobject.cpp:3633
#10 0x00007f97c9f01ee2 in QAction::triggered (this=this@entry=0x55b00525e970, 
_t1=<optimized out>) at .moc/moc_qaction.cpp:376
#11 0x00007f97c9f044f0 in QAction::activate (this=0x55b00525e970, 
event=<optimized out>) at kernel/qaction.cpp:1166
#12 0x00007f97c9fefc8d in QAbstractButtonPrivate::click (this=0x55b0053538b0) 
at widgets/qabstractbutton.cpp:397
#13 0x00007f97c9fefec5 in QAbstractButton::mouseReleaseEvent 
(this=0x55b0053533a0, e=0x7ffdca3abea0) at widgets/qabstractbutton.cpp:1011
#14 0x00007f97ca0d9c0a in QToolButton::mouseReleaseEvent (this=<optimized out>, 
e=<optimized out>) at widgets/qtoolbutton.cpp:622
#15 0x00007f97c9f467c8 in QWidget::event (this=0x55b0053533a0, 
event=0x7ffdca3abea0) at kernel/qwidget.cpp:8925
#16 0x00007f97c9ff1103 in QAbstractButton::event 
(this=this@entry=0x55b0053533a0, e=e@entry=0x7ffdca3abea0) at 
widgets/qabstractbutton.cpp:968
#17 0x00007f97ca0d9cb3 in QToolButton::event (this=0x55b0053533a0, 
event=0x7ffdca3abea0) at widgets/qtoolbutton.cpp:985
#18 0x00007f97c9f08491 in QApplicationPrivate::notify_helper 
(this=this@entry=0x55b004f5e380, receiver=receiver@entry=0x55b0053533a0, 
e=e@entry=0x7ffdca3abea0) at kernel/qapplication.cpp:3727
#19 0x00007f97c9f0fd18 in QApplication::notify(QObject*, QEvent*) () at 
kernel/qapplication.cpp:3203
#20 0x00007f97c9592039 in QCoreApplication::notifyInternal2(QObject*, QEvent*) 
() at 
../../include/QtCore/5.11.2/QtCore/private/../../../../../src/corelib/thread/qthread_p.h:307
#21 0x00007f97c9f0f019 in QCoreApplication::sendEvent (event=<optimized out>, 
receiver=<optimized out>) at 
../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:234
#22 QApplicationPrivate::sendMouseEvent 
(receiver=receiver@entry=0x55b0053533a0, event=event@entry=0x7ffdca3abea0, 
alienWidget=alienWidget@entry=0x55b0053533a0, nativeWidget=0x55b004fa5610, 
buttonDown=buttonDown@entry=0x7f97ca400870 <qt_button_down>, 
lastMouseReceiver=..., spontaneous=true) at kernel/qapplication.cpp:2695
#23 0x00007f97c9f61304 in QWidgetWindow::handleMouseEvent(QMouseEvent*) () at 
/usr/include/c++/8/bits/atomic_base.h:390
#24 0x00007f97c9f63e8e in QWidgetWindow::event (this=0x55b005079450, 
event=0x7ffdca3ac2a0) at kernel/qwidgetwindow.cpp:281
#25 0x00007f97c9f08491 in QApplicationPrivate::notify_helper 
(this=this@entry=0x55b004f5e380, receiver=receiver@entry=0x55b005079450, 
e=e@entry=0x7ffdca3ac2a0) at kernel/qapplication.cpp:3727
#26 0x00007f97c9f0fad0 in QApplication::notify(QObject*, QEvent*) () at 
kernel/qapplication.cpp:3486
#27 0x00007f97c9592039 in QCoreApplication::notifyInternal2(QObject*, QEvent*) 
() at 
../../include/QtCore/5.11.2/QtCore/private/../../../../../src/corelib/thread/qthread_p.h:307
#28 0x00007f97c993bb2b in QCoreApplication::sendSpontaneousEvent 
(event=0x7ffdca3ac2a0, receiver=0x55b005079450) at 
../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:237
#29 QGuiApplicationPrivate::processMouseEvent (e=0x55b0051a06f0) at 
kernel/qguiapplication.cpp:2081
#30 0x00007f97c993da25 in QGuiApplicationPrivate::processWindowSystemEvent 
(e=e@entry=0x55b0051a06f0) at kernel/qguiapplication.cpp:1816
#31 0x00007f97c9917d8b in QWindowSystemInterface::sendWindowSystemEvents 
(flags=...) at kernel/qwindowsysteminterface.cpp:1032
#32 0x00007f97c3c5485b in QPAEventDispatcherGlib::processEvents 
(this=0x55b004f9dda0, flags=...) at qeventdispatcher_glib.cpp:70
#33 0x00007f97c9590d0b in 
QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at 
../../include/QtCore/../../src/corelib/global/qflags.h:140
#34 0x00007f97c9598e82 in QCoreApplication::exec() () at 
../../include/QtCore/../../src/corelib/global/qflags.h:120
#35 0x000055b004050d17 in main () at ./src/main.cpp:147
#36 0x00007f97c8fefb17 in __libc_start_main (main=0x55b004050040 <main>, 
argc=1, argv=0x7ffdca3ac7e8, init=<optimized out>, fini=<optimized out>, 
rtld_fini=<optimized out>, stack_end=0x7ffdca3ac7d8) at ../csu/libc-start.c:310
#37 0x000055b0040511ca in _start () at ./src/main.cpp:130



##########


apt install xserver-xorg lightdm openbox xterm mc tmux systemd-coredump gdb 
sagemath cantor-backend-sage sagemath-dbgsym cantor-backend-sage-dbgsym 
libqt5core5a-dbgsym libqt5gui5-dbgsym libqt5widgets5-dbgsym cantor-dbgsym 
dpkg-dev devscripts quilt


# Retrieve qt5 pretty printer
mkdir .gdb
cd .gdb
git clone https://github.com/Lekensteyn/qt5printers.git
cat << EOF > qt5-gdbinit
python
import sys, os.path
sys.path.insert(0, os.path.expanduser('~/.gdb'))
import qt5printers
qt5printers.register_printers(gdb.current_objfile())
end
EOF
cd ..


mkdir cantor/orig -p
cd    cantor/orig
apt source cantor
cd ../..


mkdir qtbase-opensource-src/orig -p
cd    qtbase-opensource-src/orig
apt source qtbase-opensource-src
cd ../..


mkdir sagemath/orig -p
cd    sagemath/orig
apt source sagemath
cd ../..



(gdb) directory /home/benutzer/cantor/orig/cantor-18.08.1
(gdb) source .gdb/qt5-gdbinit

(gdb) up
#1  QString::toInt (this=<optimized out>, ok=ok@entry=0x0, base=base@entry=10) 
at tools/qstring.cpp:7078
7078    tools/qstring.cpp: Datei oder Verzeichnis nicht gefunden.
(gdb) up
#2  0x00007f97c005007d in SageSession::updateSageVersion() () at 
/usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:115
115     /usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h: Datei oder 
Verzeichnis nicht gefunden.

(gdb) set print pretty on
(gdb) set print object on




(gdb) list sagesession.cpp:462,500
462     bool SageSession::updateSageVersion()
463     {
464         QProcess get_sage_version;
465         
get_sage_version.setProgram(SageSettings::self()->path().toLocalFile());
466         get_sage_version.setArguments(QStringList()<<QLatin1String("-v"));
467         get_sage_version.start();
468         get_sage_version.waitForFinished(-1);
469         QString versionString = 
QString::fromLocal8Bit(get_sage_version.readLine());
470         QRegularExpression versionExp(QLatin1String("(\\d+)\\.(\\d+)"));
471         QRegularExpressionMatch version = versionExp.match(versionString);
472         qDebug()<<"found version: " << version.capturedTexts();
473         if(version.isValid())
474         {
475             int major=version.capturedTexts()[1].toInt();
476             int minor=version.capturedTexts()[2].toInt();
477             m_sageVersion=SageSession::VersionInfo(major, minor);
478             return true;
479         }
480         else
481             return false;
482     }



(gdb) list sagesession.cpp:112,150
112
113     void SageSession::login()
114     {
115         qDebug()<<"login";
116         emit loginStarted();
117
118         m_process=new KPtyProcess(this);
119         updateSageVersion();                                                
         <<<<<<<<<<<<<<<<<
120         const QString& sageExecFile = 
SageSettings::self()->path().toLocalFile();
121         if (m_sageVersion >= SageSession::VersionInfo(8, 4))
122             m_process->setProgram(sageExecFile, QStringList() << 
QLatin1String("--simple-prompt"));
123         else
124             {
125             const QString& sageStartScript = 
QStandardPaths::locate(QStandardPaths::GenericDataLocation, 
QLatin1String("cantor/sagebackend/cantor-execsage"));
126             m_process->setProgram(sageStartScript, 
QStringList(sageExecFile));
127             }
128
129         m_process->setOutputChannelMode(KProcess::SeparateChannels);
130         m_process->setPtyChannels(KPtyProcess::AllChannels);
131         m_process->pty()->setEcho(false);
132
133         connect(m_process->pty(), SIGNAL(readyRead()), this, 
SLOT(readStdOut()));
134         connect(m_process, SIGNAL(readyReadStandardError()), this, 
SLOT(readStdErr()));
135         connect(m_process, SIGNAL(finished ( int,  QProcess::ExitStatus )), 
this, SLOT(processFinished(int, QProcess::ExitStatus)));
136         connect(m_process, SIGNAL(error(QProcess::ProcessError)), this, 
SLOT(reportProcessError(QProcess::ProcessError)));
137         m_process->start();
138         m_process->waitForStarted();
139
140         m_process->pty()->write(initCmd);
141
142         if(!SageSettings::self()->autorunScripts().isEmpty()){
143             QString autorunScripts = 
SageSettings::self()->autorunScripts().join(QLatin1String("\n"));
144             evaluateExpression(autorunScripts, 
SageExpression::DeleteOnFinish);
145         }
146
147         emit loginDone();
148     }


############


benutzer@debian:~$ gdb -q --args cantor
Reading symbols from cantor...Reading symbols from 
/usr/lib/debug/.build-id/21/aacdb28c6d2ada77b2953bfffcd10bd2ed3947.debug...done.
done.
(gdb) set width 0
(gdb) set pagination off
(gdb) directory /home/benutzer/cantor/orig/cantor-18.08.1
Source directories searched: 
/home/benutzer/cantor/orig/cantor-18.08.1:$cdir:$cwd
(gdb) directory 
/home/benutzer/qtbase-opensource-src/orig/qtbase-opensource-src-5.11.2+dfsg/src/corelib
Source directories searched: 
/home/benutzer/qtbase-opensource-src/orig/qtbase-opensource-src-5.11.2+dfsg/src/corelib:/home/benutzer/cantor/orig/cantor-18.08.1:$cdir:$cwd
(gdb) source .gdb/qt5-gdbinit
(gdb) b QProcess::setProgram
Function "QProcess::setProgram" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (QProcess::setProgram) pending.
(gdb) run
Starting program: /usr/bin/cantor 
[Thread debugging using libthread_db enabled]
....



############


set width 0
set pagination off
directory /home/benutzer/cantor/orig/cantor-18.08.1
directory 
/home/benutzer/qtbase-opensource-src/orig/qtbase-opensource-src-5.11.2+dfsg/src/corelib
source .gdb/qt5-gdbinit
b QProcess::setProgram
y
b QProcess::setArguments
y
b QProcess::start
y
run


############


benutzer@debian:~$ strace -f -o out.txt cantor

8080  clone(child_stack=NULL, 
flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, 
child_tidptr=0x7f430f2dcad0) = 8091

8091  execve("/usr/bin/sage", ["/usr/bin/sage", "-v"], 0x7ffda123f0c8 /* 20 
vars */ <unfinished ...>



benutzer@debian:~$ /usr/bin/sage -v
/usr/bin/sage: line 16: /src/bin/sage-version.sh: No such file or directory

benutzer@debian:~$ file /usr/bin/sage
/usr/bin/sage: Bourne-Again shell script, ASCII text executable


benutzer@debian:~$ dpkg -S sage-version.sh
sagemath-common: /usr/share/sagemath/bin/sage-version.sh
benutzer@debian:~$ /usr/share/sagemath/bin/sage-version.sh
-bash: /usr/share/sagemath/bin/sage-version.sh: Permission denied
benutzer@debian:~$ sh /usr/share/sagemath/bin/sage-version.sh
benutzer@debian:~$ cat /usr/share/sagemath/bin/sage-version.sh
# Sage version information for shell scripts
# This file is auto-generated by the sage-update-version script, do not edit!
SAGE_VERSION='8.3'
SAGE_RELEASE_DATE='2018-08-03'
SAGE_VERSION_BANNER='SageMath version 8.3, Release Date: 2018-08-03'



############

root@debian:~# mkdir /src/bin -p
root@debian:~# ln -s /usr/share/sagemath/bin/sage-version.sh 
/src/bin/sage-version.sh

benutzer@debian:~$ cantor
found version:  ("8.3", "8", "3")

############


benutzer@debian:~$ /usr/bin/env bash -x /usr/bin/sage -v
++ arch
+ '[' x86_64 = mips64 -a -z '' ']'
+ '[' -v = --nodotsage ']'
+ '[' -v = -dumpversion -o -v = --dumpversion ']'
+ '[' -v = -v -o -v = -version -o -v = --version ']'
+ sage_version -v
+ '[' -f /sage-version.sh ']'
+ . /src/bin/sage-version.sh
/usr/bin/sage: line 16: /src/bin/sage-version.sh: No such file or directory
+ '[' -v = -v ']'
+ echo ''

+ exit 0


############


mc -e /usr/bin/sage

        #!/usr/bin/env bash

        # workaround #892622; unfortunately we can't simply run setarch -R when 
running Singular
        # because src/sage/libs/singular/singular.pyx loads libsingular.so into 
the current process
        if [ "$(arch)" = "mips64" -a -z "$SAGE_DEB_MIPS64_WORKAROUND" ]; then
            SAGE_DEB_MIPS64_WORKAROUND=1 exec setarch mips64 -R "$0" "$@"
        fi
            
        # Display the current version of Sage
        # usage: sage_version [-v]
        #   -v    display the full version banner including release date
        sage_version() {
            if [ -f "$SAGE_SCRIPTS_DIR/sage-version.sh" ]; then
                . "$SAGE_SCRIPTS_DIR/sage-version.sh"
            else
                . "$SAGE_ROOT/src/bin/sage-version.sh"
            fi

            if [ "$1" = "-v" ]; then
                echo "${SAGE_VERSION_BANNER}"
            else
                echo "${SAGE_VERSION}"
            fi
        }


############

benutzer@debian:~/sagemath/git$ git clone git://git.sagemath.org//sage.git


0a19135548a (Erik M. Bray          2018-04-18 14:19:48 +0000  424) 
#####################################################################
0a19135548a (Erik M. Bray          2018-04-18 14:19:48 +0000  425) # Source 
sage-env ($0 is the name of this "sage" script, so we can just
0a19135548a (Erik M. Bray          2018-04-18 14:19:48 +0000  426) # append 
-env to that). We redirect stdout to stderr, which is safer
0a19135548a (Erik M. Bray          2018-04-18 14:19:48 +0000  427) # for 
scripts.
0a19135548a (Erik M. Bray          2018-04-18 14:19:48 +0000  428) 
#####################################################################
0a19135548a (Erik M. Bray          2018-04-18 14:19:48 +0000  429) . "$0-env" 
>&2



############


Upstreams:
https://cgit.kde.org/cantor.git/tree/src/backends/sage/sagesession.cpp
https://git.sagemath.org/sage.git/tree/src/bin/sage

Issue got fixed in:
https://git.sagemath.org/sage.git/commit/?id=0a19135548a1a571b477daa9e8cbca52603efe68
Description: Move sourcing of sage-env before call to sage_version

Author: Bernhard Übelacker <bernha...@mailbox.org>
Bug-Debian: https://bugs.debian.org/911084
Forwarded: no
Last-Update: 2018-11-23

--- sagemath-8.3.orig/sage/src/bin/sage
+++ sagemath-8.3/sage/src/bin/sage
@@ -226,6 +226,24 @@ fi
 
 
 #####################################################################
+# Source sage-env ($0 is the name of this "sage" script, so we can just
+# append -env to that). We redirect stdout to stderr, which is safer
+# for scripts.
+#####################################################################
+if [ "\"$0\"" = "\"/usr/bin/sage\"" ]; then
+    . "/usr/share/sagemath/bin/sage-env" >&2
+else
+    . "$0-env" >&2
+fi
+
+if [ $? -ne 0 ]; then
+    echo >&2 "Error setting environment variables by sourcing '$0-env';"
+    echo >&2 "possibly contact sage-devel (see http://groups.google.com/group/sage-devel)."
+    exit 1
+fi
+
+
+#####################################################################
 # Report information about the Sage environment
 #####################################################################
 
@@ -254,24 +272,6 @@ if [ $# -gt 0 ]; then
 fi
 
 
-#####################################################################
-# Source sage-env ($0 is the name of this "sage" script, so we can just
-# append -env to that). We redirect stdout to stderr, which is safer
-# for scripts.
-#####################################################################
-if [ "\"$0\"" = "\"/usr/bin/sage\"" ]; then
-    . "/usr/share/sagemath/bin/sage-env" >&2
-else
-    . "$0-env" >&2
-fi
-
-if [ $? -ne 0 ]; then
-    echo >&2 "Error setting environment variables by sourcing '$0-env';"
-    echo >&2 "possibly contact sage-devel (see http://groups.google.com/group/sage-devel)."
-    exit 1
-fi
-
-
 # Prepare for running Sage, either interactively or non-interactively.
 sage_setup() {
     # Check that we're not in a source tarball which hasn't been built yet (#13561).

Reply via email to