Skip to content

Undefined behavior in base64.h due to storing EOF in char type #2254

Description

@chyunsu3

Related: dmlc/xgboost#3976.

Currently, base64 stream stores EOF in a char variable, which may cause undefined behavior for ARM targets.

Details. std::istream.get() and getchar() have return type int, not char, because both may return EOF, which is commonly -1. Storing EOF in a char results in undefined behavior. The char type is usually signed on x86 systems but unsigned on ARM systems (see http://blog.cdleary.com/2012/11/arm-chars-are-unsigned-by-default/), so the undefined behavior will only be apparent when compiled on ARM.

Aside. AWS has recently begun offering ARM-backed EC2 instances.

Activity

  1. chyunsu3 commented on Dec 7, 2018

    @chyunsu3
    ContributorAuthor

    #2255 should address this issue.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions