Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using [1] instead of [] breaks the strict bounds checks. #564

Open
krlmlr opened this issue Jan 6, 2025 · 0 comments
Open

Using [1] instead of [] breaks the strict bounds checks. #564

krlmlr opened this issue Jan 6, 2025 · 0 comments

Comments

@krlmlr
Copy link
Member

krlmlr commented Jan 6, 2025

From CRAN:

We are seeing UBSAN errors in CRAN packages

CAESAR.Suite Cyclops GRIN2 LowWAFOMNX MOCHA Mega2R PAMmisc PANACEA
RecordLinkage SSN2 WGCNA bigsnpr dexter dexterMST epoxy glue idem
netgsa prqlr qtl2 rliger sf snplist storr stream survey taxonomizr winch

most at

vendor/sqlite3/sqlite3.c:111455:20: runtime error: index 2 out of bounds for type 'ExprList_item [1]'
#0 0x7f88b04dd803 in sqlite3ExprListAppend vendor/sqlite3/sqlite3.c:111455

We have been here before: it is found by -fsanitize=strict-bounds in GCC.

This comes from

struct ExprList {
  int nExpr;             /* Number of expressions on the list */
  int nAlloc;            /* Number of a[] slots allocated */
  struct ExprList_item { /* For each expression in the list */
    Expr *pExpr;            /* The parse tree for this expression */
    char *zEName;           /* Token associated with this expression */
    struct {
      u8 sortFlags;           /* Mask of KEYINFO_ORDER_* flags */
      unsigned eEName :2;     /* Meaning of zEName */
      unsigned done :1;       /* Indicates when processing is finished */
      unsigned reusable :1;   /* Constant expression is reusable */
      unsigned bSorterRef :1; /* Defer evaluation until after sorting */
      unsigned bNulls :1;     /* True if explicit "NULLS FIRST/LAST" */
      unsigned bUsed :1;      /* This column used in a SF_NestedFrom subquery */
      unsigned bUsingTerm:1;  /* Term from the USING clause of a NestedFrom */
      unsigned bNoExpand: 1;  /* Term is an auxiliary in NestedFrom and should
                              ** not be expanded by "*" in parent queries */
    } fg;
    union {
      struct {             /* Used by any ExprList other than Parse.pConsExpr */
        u16 iOrderByCol;      /* For ORDER BY, column number in result set */
        u16 iAlias;           /* Index into Parse.aAlias[] for zName */
      } x;
      int iConstExprReg;   /* Register in which Expr value is cached. Used only
                           ** by Parse.pConstExpr */
    } u;
  } a[1];                  /* One slot for each expression in the list */
};

That is pre-C99 code, and should be a[].

similarly,

  u32 aType[1];           /* Type values record decode.  MUST BE LAST */
  CollSeq *aColl[1];  /* Collating sequence for each term of the key */

should be []

Temporarily we have installed RSQLite without using strict-bounds.

Packages GRIN2 Mega2R ProFAST dexter dexterMST rliger

show another issue

vendor/sqlite3/sqlite3.c:79337:14: runtime error: load of address 0x7f2fb0869240 with insufficient space for an object of type 'struct MemPage *'

at

balance_nonroot vendor/sqlite3/sqlite3.c:79337

Please investigate and if necessary report upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant