This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/19361] New: Invalid comparison functions


https://sourceware.org/bugzilla/show_bug.cgi?id=19361

            Bug ID: 19361
           Summary: Invalid comparison functions
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: tetra2005 at gmail dot com
  Target Milestone: ---

Created attachment 8846
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8846&action=edit
Proposed patch

Comparison functions qsort_cmp and compare_processes (used in qsort) do not
obey to standard symmetry requirements which causes undefined behavior. The
latter may result in strange runtime bugs.

Compare_processes fails to properly compare process group leaders which is
probably a serious problem (e.g. resulting in invalid sort).

Qsort_cmp fails to produce proper result when comparing same element. Sane
qsort implementation probably don't call comparison callback on same element so
this may not be a big problem in practice.

I've attached simple patches which correct both errors.

Bugs were found with SortChecker tool (https://github.com/yugr/sortcheck).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]