Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Simple program goes into infinite loop #796

@bingatgoogle

Description

@bingatgoogle

The following program prints the message infinitely times, under the opt mode.

#include <glog/logging.h>

// * bazel run -c opt visionai/issues:overflow_plus_logging will invoke an
//     infinite loop.
// * -c dbg works fine.

int main (int argc, char* argv[]) {
  ::google::InitGoogleLogging(argv[0]);
  for (int i = 1; i <= 2; i++) {
    LOG(ERROR) << "should only output just twice";
    uint64_t a = i * 2147483647;
  }
  return 0;
}

Sample output:

......
E20220220 22:38:17.697548 1707658 overflow_plus_logging.cc:10] should only output just twice
E20220220 22:38:17.697566 1707658 overflow_plus_logging.cc:10] should only output just twice
E20220220 22:38:17.697582 1707658 overflow_plus_logging.cc:10] should only output just twice
E20220220 22:38:17.697598 1707658 overflow_plus_logging.cc:10] should only output just twice
E20220220 22:38:17.697614 1707658 overflow_plus_logging.cc:10] should only output just twice
E20220220 22:38:17.697630 1707658 overflow_plus_logging.cc:10] should only output just twice
E20220220 22:38:17.697647 1707658 overflow_plus_logging.cc:10] should only output just twice
E20220220 22:38:17.697664 1707658 overflow_plus_logging.cc:10] should only output just twice
......

BUILD file:

cc_binary(
    name = "overflow_plus_logging",
    srcs = [
        "overflow_plus_logging.cc",
    ],
    deps = [
        "@com_github_google_glog//:glog",
    ],
)

uname -a: Linux 276db1447620 5.14.16-1rodete1-amd64 #1 SMP Debian 5.14.16-1rodete1 (2021-11-17) x86_64 GNU/Linux
Bazel version: 5.0.0
gcc version: gcc version 8.3.0 (Debian 8.3.0-6)
Bazel workspace:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "com_github_gflags_gflags",
    sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf",
    strip_prefix = "gflags-2.2.2",
    urls = ["https://github.com/gflags/gflags/archive/v2.2.2.tar.gz"],
)

http_archive(
    name = "com_github_google_glog",
    sha256 = "21bc744fb7f2fa701ee8db339ded7dce4f975d0d55837a97be7d46e8382dea5a",
    strip_prefix = "glog-0.5.0",
    urls = ["https://github.com/google/glog/archive/v0.5.0.zip"],
)

Docker file if helpful:

FROM debian

ENV ROOTPATH=/
WORKDIR $ROOTPATH

RUN apt-get update && apt-get install -y --no-install-recommends \
      build-essential \
      ca-certificates \
      curl \
      vim \
      && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
      git \
      gnupg \
      && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Install bazel
RUN curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg \
      --dearmor > bazel.gpg && \
    mv bazel.gpg /etc/apt/trusted.gpg.d/ && \
    echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | \
      tee /etc/apt/sources.list.d/bazel.list && \
    apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
      bazel \
      && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

CMD ["bash"]

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