bugGNU Octave - Bugs: bug #66989, (signal) UBSAN warnings

 
 

bug #66989: (signal) UBSAN warnings

Submitter:  Dmitri A. Sergatskov <dasergatskov>
Submitted:  Fri 04 Apr 2025 02:27:39 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Release: 
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 04 Apr 2025 03:35:21 AM UTC, comment #1: 

15 failures is due to clang not linking in "libquadmath" library.
It would be niceto fix that, but it is  a separate subject.
 
Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 04 Apr 2025 02:27:39 AM UTC, original submission:  

Running "pkg test signal" compiled with clang version 20.1.1 (Fedora 20.1.1-1.fc42) and "-Og -fsanitize=undefined" flags:

  ..ackages/signal-1.4.6/x86_64-pc-linux-gnu-api-v60/cl2bp.cc-tst cl2bp_lib.h:59:17: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/string.h:61:62: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior cl2bp_lib.h:59:17
 pass    1/1    [ 0.010s /  0.010s]
  ..ackages/signal-1.4.6/x86_64-pc-linux-gnu-api-v60/firpm.cc-tst mmfir.c:218:31: runtime error: signed integer overflow: 1664525 * 1013904223 cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior mmfir.c:218:31
mmfir.c:218:31: runtime error: signed integer overflow: 1854562261 + 1013904223 cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior mmfir.c:218:31
 pass   37/52   [11.749s /  0.423s]
                                                                   FAIL   15


The warnings can be fixed with:


--- a/src/cl2bp_lib.h   Tue Apr 01 07:58:23 2025 -0400
+++ b/src/cl2bp_lib.h   Thu Apr 03 22:17:42 2025 -0400
@@ -56,7 +56,7 @@
     assert(length_ >= 0 && length_ <= 512*1024*1024);  // verify that the array size is reasonable
     length = length_;
     ptr = (T *)realloc(ptr, length * sizeof(T));
-    std::memset(ptr, 0, length * sizeof(T));
+    if (ptr) std::memset(ptr, 0, length * sizeof(T));
   }

   MallocArray(int length_=0) {


and



--- a/src/mmfir.c       Tue Apr 01 07:58:23 2025 -0400
+++ b/src/mmfir.c       Thu Apr 03 22:17:42 2025 -0400
@@ -78,7 +78,7 @@
 #define maxPeaks        (R+1+maxExtras)
 #define PI              3.1415926535897932384626433832795029
 #define rand(r,x)       (ranqd1(r) * ((x) / (65536. * 32768.))) // in [-x,x)
-#define ranqd1(r)       ((r) = 1664525 * (r) + 1013904223) // int32_t r
+#define ranqd1(r)       ((r) = (rand_t)((1664525 * (unsigned long)(r) + 1013904223UL)& 0xFFFFFFFFUL))  // int32_t r
 #define returnError(x)  do {report.result=x; goto END;} while(0)
 #define iround(x)       (int)floor((x)+.5)
 #define setF(F)         for (f=(F); f>b->freqR; ++b)


I still get 15 errors. (file "fntests.log") is attached.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #57100:  fntests.log added by dasergatskov (46KiB - text/x-log)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dasergatskov (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.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-04-04 dasergatskov Attached File- Added fntests.log, #57100

    Back to the top

    Powered by Savane 3.14-962f.
    Corresponding source code