Skip to content

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

@hcho3

Description

@hcho3

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.

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