bugGNU Octave - Bugs: bug #47840, exec segfaults on Windows


bug #47840: exec segfaults on Windows

Submitter:  Tatsuro MATSUOKA <tmacchant>
Submitted:  Tue 03 May 2016 11:01:38 PM UTC
Category:  Interpreter Severity:  2 - Minor
Priority:  3 - Low Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  Tatsuro MATSUOKA Open/Closed:  * Closed
Release:  * other Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


( Jump to the original submission )

Fri 14 May 2021 02:24:35 PM UTC, comment #6: 

The POSIX documentation for "exec" states:

>        The exec() family of functions replaces the current process image
>        with a new process image.

IIUC, that means that the Octave process is replaced by the new process. That means that Octave stops executing as the other process starts.
It looks like this is happening on Windows 10. I don't see any error message (with CLI or with GUI).

If I attach gdb to Octave 6.2.0 and run an "exec" command, I see:

[Inferior 1 (process 11780) exited normally]

It looks like the segfault on exit has been fixed some time on the way.

Closing report.

Markus M├╝tzel <mmuetzel>
Project Member
Sat 02 Jul 2016 05:38:49 PM UTC, comment #5: 

Changing the severity of this bug to Minor, which means it will not impact the 4.2 release.  Although it would be nice to have exec working, it is not a frequently used function.

Rik <rik5>
Project Administrator
Thu 05 May 2016 12:22:28 AM UTC, comment #4: 

I have execute octave-4.0.2 self built on windows.

I ran ./run-octave -g --no-gui

(gdb) break oct-syscalls.cc:77
No source file named oct-syscalls.cc.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (oct-syscalls.cc:77) pending.
(gdb) run
GNU Octave, version 4.0.2
Copyright (C) 2016 John W. Eaton and others.
>> exec("ls", "-l")
total 5105
-rw-r--r--  1 MATSUOKA LAB Administrators  105722 May  1 10:31 Makefile
-rw-r--r--  1 MATSUOKA LAB Administrators  111752 May  1 10:32 config.h
-rw-r--r--  1 MATSUOKA LAB Administrators 4474379 May  1 10:32 config.log
-rwxr-xr-x  1 MATSUOKA LAB Administrators  141761 May  1 10:31 config.status
drwxr-xr-x  6 MATSUOKA LAB Administrators    4096 May  1 10:31 doc
drwxr-xr-x  3 MATSUOKA LAB Administrators       0 May  1 09:21 etc
drwxr-xr-x  4 MATSUOKA LAB Administrators       0 May  1 10:31 examples
drwxr-xr-x  5 MATSUOKA LAB Administrators   40960 May  1 15:24 libgnu
drwxr-xr-x  8 MATSUOKA LAB Administrators    4096 May  1 16:39 libgui
drwxr-xr-x 10 MATSUOKA LAB Administrators    4096 May  1 16:33 libinterp
drwxr-xr-x 10 MATSUOKA LAB Administrators    4096 May  1 15:50 liboctave
-rwxr-xr-x  1 MATSUOKA LAB Administrators  306003 May  1 10:32 libtool
-rw-r--r--  1 MATSUOKA LAB Administrators    4197 May  1 10:31 oct-conf-post.h
-rw-r--r--  1 MATSUOKA LAB Administrators      43 May  1 11:33 octave-workspace
-rwxr-xr-x  1 MATSUOKA LAB Administrators    4063 May  1 10:42 run-octave
drwxr-xr-x 31 MATSUOKA LAB Administrators    8192 May  1 16:41 scripts
drwxr-xr-x  4 MATSUOKA LAB Administrators    4096 May  1 16:40 src
-rw-r--r--  1 MATSUOKA LAB Administrators      23 May  1 10:32 stamp-h1
drwxr-xr-x 17 MATSUOKA LAB Administrators    4096 May  2 07:40 test
[Inferior 1 (process 6448) exited with code 0377]
(gdb) bt
No stack.

At the moment, I could not get useful information.
In addition, I failed to set break point at octave_syscalls::execvp on gdb. Perhaps this is my mistake to set a break point.

Tatsuro MATSUOKA <tmacchant>
Wed 04 May 2016 03:08:01 AM UTC, comment #3: 

understood. was mixing up exec and system, I guess, and misinterpreted the issue.

Nicholas Jankowski <nrjank>
Project Member
Wed 04 May 2016 02:55:27 AM UTC, comment #2: 

>> exec("pause")
ans = -1

"pause" is internal command in cmd.exe so that you cannot directly
execute it. Therefore this is correct response because pause
itself cannot be found.

>> exec("cmd", "/c pause")

is correct usage
And this causes the same phenomena as those caused by exec("ls", "-l")

Tatsuro MATSUOKA <tmacchant>
Wed 04 May 2016 01:43:08 AM UTC, comment #1: 

Just to add to the data set:

Running 4.0.1 on Windows 7 (installed from zip file, not exe installer)

running exec("ls","-l") from octave gui  closes Octave.  after some time a message appears

octave-gui.exe has stopped working

A problem caused the program to stop working correctly. Please close the program.


wondering if it would be different if a command was executed that should wait for user input, I tried:

>> exec("pause")
ans = -1

no window or anything appears.

wondering if passing the argument was involved:

>> exec("pause", "-h")
ans = -1

running octave-cli after starting from a windows CMD shell, I get the same behavior. the only difference is the error message indicates octave-cli.exe has crashed. then it drops be back to the shell command line.

Nicholas Jankowski <nrjank>
Project Member
Tue 03 May 2016 11:01:38 PM UTC, original submission:  

This originally posted in Octave-Maintainers ML.

exec : typo in documents and erroneously terminates on native windows

Re: exec segfaults on Windows.

I re-writes here what happens on windows.

>> exec("ls", "-l")

This command executes "ls" on the shell and octave terminates.
On windows 10 "ls" works but give an error in terminating octave process. Windows gave an error message dialog like:

Dialog written in Japanese so that I made a translation.

 Octave-cli is terminated.
 Problems occurred and program does not work correctly.
 Program is terminated by windows system.
 If there is a solution, it is reported from windows system.
    (Button [Terminate program])

On 4.0.2-cli in a Windows XP virtual machine (by Rik)

>> exec ('dir')
panic: Segmentation violation -- stopping myself...
attempting to save variables to 'octave-workspace'...
abc                IETldCache         ntuser.dat.LOG        SendTo
Application Data  Local Settings    ntuser.ini            Start Menu
Cookies            MapSetToolKit.cfg  PrintHood             Templates
Desktop            My Documents      PrivacIE              UserData
Favorites          NetHood            QBInstanceFinder.log  WINDOWS
g2mdlhlpx.exe      NTUSER.DAT         Recent

Tatsuro MATSUOKA <tmacchant>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by tmacchant (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.





    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-05-14 mmuetzel StatusNone Fixed
        Open/ClosedOpen Closed
    2016-07-02 rik5 Severity4 - Important 2 - Minor
        Priority5 - Normal 3 - Low
    2016-07-01 rik5 Severity3 - Normal 4 - Important

    Back to the top

    Powered by Savane 3.9