Skip to content

memrchr uses unaligned loads #35967

Description

@bluss

Due to an arithmetic error, the fallback memrchr (used for non-linux) in libstd uses unaligned loads, the intention was to produce only well aligned pointers of course.

This was suspected to cause a crash using ARMv7, found by @tomaka

Original code also had the same issue: BurntSushi/memchr/pull/9

I believe that on x86 non-linux platforms, the bug was harmless and the function still produced the correct return value.

Activity

  1. added
    I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
    on Aug 24, 2016
  2. tomaka commented on Aug 24, 2016

    @tomaka
    Contributor

    This was suspected to cause a crash using ARMv7, found by @tomaka

    The crash is a SIGBUS (which is usually caused by unaligned loads), so this is likely the cause.

    If anyone want to find more, the exact location is _ZN3std6memchr7memrchr17hbaa18487c977cd24E+164, using the rustc nightly from 2016-08-18. I don't know how to introspect the debug infos to find what exactly is the instruction at this location. EDIT: Oh, since libstd is compiled in release there's probably no debug info anyway.

  3. bluss commented on Aug 24, 2016

    @bluss
    ContributorAuthor

    If you have the time, you can try with the posted PR #35969 to verify the fix.

  4. bluss commented on Aug 27, 2016

    @bluss
    ContributorAuthor

    @tomaka how relevant is this platform for stable rust? Should we beta-nominate the fix?

  5. tomaka commented on Aug 28, 2016

    @tomaka
    Contributor

    The crash disappeared after the latest nightly.

  6. bluss commented on Aug 29, 2016

    @bluss
    ContributorAuthor

    Thank you

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions