bugGNU Octave - Bugs: bug #67258, Bad memory access when trying to...

 
 

bug #67258: Bad memory access when trying to integrate 1/sqrt(x) in 'quadv.m'

Submitter:  Thomas <kolmanthomas>
Submitted:  Sat 28 Jun 2025 05:15:02 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  None Assigned to:  None
Originator Name:  Thomas Open/Closed:  * Open
Release:  * dev Release: 
Operating System:  * Mac OS Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 11 Jul 2025 11:41:10 PM UTC, comment #9: 

For what it's worth, I can't reproduce this bug anymore after updating all my packages through Homebrew and pulling the latest Octave sources... so I suppose the report can be closed unless someone else has this issue.

Thank you Dmitri for sharing your build flags, it was actually very helpful in general.

Thomas <kolmanthomas>
Sat 28 Jun 2025 06:50:35 PM UTC, comment #8: 

Those are my flags:

octave:1> __octave_config_info__ ("config_opts")
ans =  '--without-x' '--with-blas=-lopenblas' '--with-java-homedir=/opt/homebrew/opt/openjdk' 'CC=clang' 'CXX=clang++ -std=gnu++17' 'CFLAGS=-g3 -Og -march=native' 'CXXFLAGS=-g3 -Og -march=native' 'FFLAGS=-g2 -Og -march=native' '--disable-std-pmr-polymorphic-allocator' 'LDFLAGS=-L/usr/local/lib -L/opt/homebrew/lib -L/opt/homebrew/opt/libiconv/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/openblas/lib' 'CPPFLAGS=-I/opt/homebrew/include -I/opt/homebrew/opt/libiconv/include -I/opt/homebrew/opt/readline/include' '--disable-java' '--disable-docs' '--enable-address-sanitizer-flags'


Dmitri A. Sergatskov <dasergatskov>
Sat 28 Jun 2025 06:43:03 PM UTC, comment #7: 

It also looks like you get a recursion that does not converge and eventually exhausts the stack. I had seen this before (usually with new compiler releases, with fresh bugs etc) when I was using high optimization level.
So I am not convinced that this is octave issue.
Try to recompile setting compiler flags per:
https://wiki.octave.org/wiki/index.php?title=Finding_Memory_Leaks
(I usually set optimization to "-Og" so it runs a little faster than "-O0"). Disable java (it tends to mess-up with debugger), and try again.

The only problem I see on my computer is "test ilu".

Dmitri.
--


Dmitri A. Sergatskov <dasergatskov>
Sat 28 Jun 2025 06:41:35 PM UTC, comment #6: 

I use Homebrew, I run a few export commands before I configure


export YACC=$(brew --prefix bison)/bin/bison && \
export BISON=$(brew --prefix bison)/bin/bison && \
./ configure --prefix=$HOME/my_octave \
LDFLAGS="-L/usr/local/opt/openblas/lib -L/usr/local/opt/bison/lib -L /usr/local/opt/readline/lib" \
CXXFLAGS="-I/usr/local/opt/openblas/include -I/usr/local/opt/ readline/include -fsanitize=address -std=gnu ++17 -g" \


I use Apple Clang, the '-std=gnu++17' flag is a holdover from using GCC previously but it should be equivalent to '-std=c++17' with some conforming GNU extensions (see https://clang.llvm.org/docs/CommandGuide/clang.html, ctrl/cmd-F 'gnu++17')

As for the Fortran flags, I don't really know what I should look for, I've never manually set a Fortran flag. I might be missing something, but I don't see any calls to Fortran code in quadv.m.

I will trying compiling in a Linux VM to see if I can reproduce the issue.

Thomas <kolmanthomas>
Sat 28 Jun 2025 06:13:46 PM UTC, comment #5: 

What do you use for GNU packages, Homebrew, macports, something else? Which compiler do you use Apple's clang, or gcc?

Usually one would use `--enable-address-sanitizer-flags` passed to configure to proper set up "sanitize=address" flags.

I think "quadv" uses Fortran library, so what are the Fortran flags?

Dmitri.
--


Dmitri A. Sergatskov <dasergatskov>
Sat 28 Jun 2025 06:04:25 PM UTC, comment #4: 

I've attached the result of 'bt all'.

(file #57343)

Thomas <kolmanthomas>
Sat 28 Jun 2025 05:57:03 PM UTC, comment #3: 

It's reproducible, I can generate this crash with two different builds of Octave. I'm running this code from the command-line interpreter, but I tested it with the GUI and it produces the same crash.
 
Here's my configure settings

./configure --prefix=$HOME/my_octave \
LDFLAGS="-L/usr/local/opt/openblas/lib -L/usr/local/opt/bison/lib -L/usr/local/opt/readline/lib" \
CXXFLAGS="-I/usr/local/opt/openblas/include -I/usr/local/opt/readline/include -fsanitize=address -std=gnu++17 -g" \


Thomas <kolmanthomas>
Sat 28 Jun 2025 05:54:50 PM UTC, comment #2: 

Do you have an entire crash stack, rather than a crashing thread only?
(I think it is "bt all" in lldb)

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Sat 28 Jun 2025 05:43:28 PM UTC, comment #1: 

Is it reproducible?
I cannot get the crash on my computer.
Are you running this from GUI?
What kind of optimization do you have for compilers (clang and gfortran)?

To me it looks like a thread contention between pager and a GUI.

Dmitri.
--


Dmitri A. Sergatskov <dasergatskov>
Sat 28 Jun 2025 05:15:02 PM UTC, original submission:  

Running 'test quadv.m' produces an error on MacOS that immediately crashes the interpreter. I've attached the full backtrace from lldb as a file. I've built my Octave from the latest dev sources using ASAN enabled.

Specifically, what causes the crash is the code


%!assert (quadv (@(x) [ x,x,x; x,1./sqrt(x),x; x,x,x ], 0, 1),
%!        [0.5,0.5,0.5; 0.5,2,0.5; 0.5,0.5,0.5], 15*1e-6);


The offending part can be narrowed down to trying to integrate


> f = @(x) 1/sqrt(x);
> quadv(f, 0, 1)


I've narrowed it down to crashed exactly on a call to 'feval ( @(x) 1/sqrt(x), d);' after a few recursive calls to the function 'simsonstp'. The value of the variable 'd' is positive at the time of the call.

The above code works totally fine on the MacOS Homebrew (9.4.0) version, and I don't see a commit to quadv.m between that version and recent sources, so I don't really have a clue what's going on.

Thomas <kolmanthomas>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #57343:  backtrace_quadv2.m added by kolmanthomas (105KiB - application/octet-stream)
file #57342:  backtrace_quadv.txt added by kolmanthomas (103KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by kolmanthomas (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 group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-06-28 kolmanthomas Attached File- Added backtrace_quadv2.m, #57343
    2025-06-28 kolmanthomas Attached File- Added backtrace_quadv.txt, #57342

    Back to the top

    Powered by Savane 3.15-e6e5.
    Corresponding source code