Skip to content

[Bug]: user-provided comparison function does not correctly implement a total order #346

@ddxtanx

Description

@ddxtanx

Bug Description

When extracting text from a PDF, extraction fails and panics with the aforementioned error. See reproduction and PDF sections for explicit details.

Steps to Reproduce

  1. Open attached PDF as PdfDocument
  2. Extract text on 15th page
  3. Panic

Expected Behavior

Should extract text without error

Actual Behavior

thread '' (1716332) panicked at /rustc/e408947bfd200af42db322daf0fadfe7e26d3bd1/library/core/src/slice/sort/shared/smallsort.rs:860:5:
user-provided comparison function does not correctly implement a total order

PDF Information (if applicable)

Title:
Subject:
Keywords:
Author:
Creator: LaTeX with hyperref package
Producer: pdfTeX-1.40.10
CreationDate: Tue Jun 18 18:54:59 2013 CDT
ModDate: Tue Jun 18 18:54:59 2013 CDT
Custom Metadata: yes
Metadata Stream: no
Tagged: no
UserProperties: no
Suspects: no
Form: none
JavaScript: no
Pages: 29
Encrypted: no
Page size: 612 x 792 pts (letter)
Page rot: 0
File size: 4143486 bytes
Optimized: no
PDF version: 1.4

1008.3918v2.pdf

Environment

  • OS: Arch Linux x86_64 kernel Linux 6.19.11-arch1-1
  • Rust version: rustc 1.94.1 (e408947bf 2026-03-25)
  • pdf_oxide version: 0.3.30
  • Python version (if using Python bindings): Python 3.12.13

Code Sample

import pdf_oxide
import os

doc = pdf_oxide.PdfDocument("1008.3918v2.pdf")
doc.extract_text(14)

Error Messages / Logs

XY-cut: horizontal projection width 18446744073709551615 exceeds MAX_PROJECTION_SIZE 100000, skipping region (degenerate CTM?)
XY-cut: vertical projection height 18446744073709551615 exceeds MAX_PROJECTION_SIZE 100000, skipping region (degenerate CTM?)
thread '<unnamed>' (1715069) panicked at /rustc/e408947bfd200af42db322daf0fadfe7e26d3bd1/library/core/src/slice/sort/shared/smallsort.rs:860:5:
user-provided comparison function does not correctly implement a total order
stack backtrace:
   0:     0x7fc46ceec92d - <unknown>
   1:     0x7fc46cd2bc8a - <unknown>
   2:     0x7fc46ceebc25 - <unknown>
   3:     0x7fc46ceeb89e - <unknown>
   4:     0x7fc46cf142e8 - <unknown>
   5:     0x7fc46cf14269 - <unknown>
   6:     0x7fc46cf1425c - <unknown>
   7:     0x7fc46cd2cc5b - <unknown>
   8:     0x7fc46cd3785c - <unknown>
   9:     0x7fc46ca0aab0 - <unknown>
  10:     0x7fc46ca0a4fd - <unknown>
  11:     0x7fc46ca0a4fd - <unknown>
  12:     0x7fc46ca0a4fd - <unknown>
  13:     0x7fc46ca0a4fd - <unknown>
  14:     0x7fc46c9a1bb2 - <unknown>
  15:     0x7fc46ccc3424 - <unknown>
  16:     0x7fc46ccb427d - <unknown>
  17:     0x7fc46cc40d1e - <unknown>
  18:     0x7fc46cc5728c - <unknown>
  19:     0x7fc46cb89b1a - <unknown>
  20:     0x7fc46cba209d - <unknown>
  21:     0x7fc46ca26999 - <unknown>
  22:     0x7fc46ca270d1 - <unknown>
  23:          0x16618df - method_vectorcall_VARARGS_KEYWORDS.llvm.1737398267797123166
  24:          0x1615390 - _PyEval_EvalFrameDefault
  25:          0x1624a7c - starmap_next
  26:          0x160620c - list_extend.llvm.18079795460131492206
  27:          0x1605f32 - list_vectorcall
  28:          0x1615390 - _PyEval_EvalFrameDefault
  29:          0x1690360 - PyEval_EvalCode
  30:          0x16ac709 - run_mod.llvm.407189894156170949
  31:          0x1775260 - PyRun_SimpleStringFlags
  32:          0x18e0115 - Py_RunMain.warm
  33:          0x1789bd8 - pymain_main.llvm.6253847990387534877
  34:          0x17899ec - main
  35:     0x7fc46db726c1 - <unknown>
  36:     0x7fc46db727f9 - __libc_start_main
  37:          0x17af1a9 - _start
  38:                0x0 - <unknown>
Traceback (most recent call last):
  File "<stdin>", line 6, in <module>
pyo3_runtime.PanicException: user-provided comparison function does not correctly implement a total order

Additional Context

No response

Checklist

  • I have searched existing issues to make sure this is not a duplicate
  • I have provided all required information above
  • I am using the latest version of pdf_oxide

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions