Skip to content

Commit

Permalink
fix segfault pertaining to sliding window bounds (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
fenollp authored Oct 29, 2021
1 parent 1226820 commit fc05e22
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1.2@sha256:e2a8561e419ab1ba6b2fe6cbdf49fd92b95912df1cf7d313c3e2230a333fdbcc
# syntax=docker/dockerfile:1@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2

FROM ubuntu:20.04@sha256:82becede498899ec668628e7cb0ad87b6e1c371cb8a1e597d83a47fac21d6af3 AS base
WORKDIR /app
Expand Down
34 changes: 17 additions & 17 deletions resolved.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ resolved = [
"rule_class": "@bazel_upgradable//:rule.bzl%upgradable_repository",
"attributes": {
"urls": [
"https://github.com/glfw/glfw/archive/d3317b49373ced81a458008316dd5b6115d26df8.tar.gz",
"https://github.com/glfw/glfw/archive/19543afbfb3856e5ef7d5954ad795e1077e82550.tar.gz",
],
"sha256": "de8cd84b459d8d1df436c0c2514897b9799ee5f3b3aa502a930e2a9ab97c6ad3",
"sha256": "5ba92275b87d329ec4cd21a257a3c295cfd471a86a254aa45434936af241da4d",
"netrc": "",
"auth_patterns": {},
"canonical_id": "",
"strip_prefix": "glfw-d3317b49373ced81a458008316dd5b6115d26df8",
"strip_prefix": "glfw-19543afbfb3856e5ef7d5954ad795e1077e82550",
"type": "tar.gz",
"patches": [],
"patch_tool": "",
Expand All @@ -245,7 +245,7 @@ resolved = [
"tag": "",
"name": "glfw",
},
"output_tree_hash": "a44caf5df5fe2d060e86988112e45161c0dc141056570e91d7f692097391288f",
"output_tree_hash": "aa4553b4aa77802e88433412d94f2e14978416a65a2c25ff62c8a45e4cc4fd93",
},
],
},
Expand All @@ -264,13 +264,13 @@ resolved = [
"rule_class": "@bazel_upgradable//:rule.bzl%upgradable_repository",
"attributes": {
"urls": [
"https://github.com/glfw/glfw/releases/download/3.3.4/glfw-3.3.4.bin.MACOS.zip",
"https://github.com/glfw/glfw/releases/download/3.3.5/glfw-3.3.5.bin.MACOS.zip",
],
"sha256": "05acdcbbc1f69ac425cc6fa09cc13f1d21993a29cbdebb09f413c2f99358785c",
"sha256": "184f165464ed9c46effd96c9fb6e355996d62f5f96f5e90542f00775fe781511",
"netrc": "",
"auth_patterns": {},
"canonical_id": "",
"strip_prefix": "glfw-3.3.4.bin.MACOS",
"strip_prefix": "glfw-3.3.5.bin.MACOS",
"type": "zip",
"patches": [],
"patch_tool": "",
Expand All @@ -288,7 +288,7 @@ resolved = [
"tag": "~3",
"name": "glfw_osx",
},
"output_tree_hash": "f1b4276aef9a555c6da8916e891083ff3de54e8e340b8ab896e751ca47a8f6d9",
"output_tree_hash": "8bfd001632546166c2d147f2921c40a105029eef8d05166ddce756a01174e125",
},
],
},
Expand Down Expand Up @@ -345,13 +345,13 @@ resolved = [
"rule_class": "@bazel_upgradable//:rule.bzl%upgradable_repository",
"attributes": {
"urls": [
"https://github.com/KhronosGroup/OpenGL-Registry/archive/6eca3c2cdc3d1a1147302052e1f1f61cc487b79b.tar.gz",
"https://github.com/KhronosGroup/OpenGL-Registry/archive/b7532263e5a6bb505413786fa4926f4f0f010514.tar.gz",
],
"sha256": "73f342d9b2e50f91237bddca9c6e06b5fa8d99607337c169266cecbe0f884dce",
"sha256": "92fbdfb27e59269c092861c94fc14b198c644a83a6ff21118a9b8bdb2d186f10",
"netrc": "",
"auth_patterns": {},
"canonical_id": "",
"strip_prefix": "OpenGL-Registry-6eca3c2cdc3d1a1147302052e1f1f61cc487b79b",
"strip_prefix": "OpenGL-Registry-b7532263e5a6bb505413786fa4926f4f0f010514",
"type": "tar.gz",
"patches": [],
"patch_tool": "",
Expand All @@ -369,7 +369,7 @@ resolved = [
"tag": "",
"name": "khronos_opengl_registry",
},
"output_tree_hash": "f4a107a39ff68b52867d95b74ce3698766d8debfc875135f3ccd51098f909089",
"output_tree_hash": "00e357d6bac3a210b1c0e570c898cd98548f36d3afc0f15679a7c10716095e82",
},
],
},
Expand All @@ -385,14 +385,14 @@ resolved = [
"rule_class": "@bazel_upgradable//:rule.bzl%upgradable_repository",
"attributes": {
"urls": [
"https://github.com/bazelbuild/rules_cc/archive/d66a13e2a01630afcafc4ba411d83e291ecf02bd.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/d66a13e2a01630afcafc4ba411d83e291ecf02bd.tar.gz",
"https://github.com/bazelbuild/rules_cc/archive/f84656686987ce254481cc33efa3b6645d4254c3.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/f84656686987ce254481cc33efa3b6645d4254c3.tar.gz",
],
"sha256": "3cde212ccda3ba152897e7fd354c42eba275878b6d98fe4f2125c684a73f3842",
"sha256": "a30681f34021a77638b07abcea132d0057aa16d81e76444b4c454c29ae59fac0",
"netrc": "",
"auth_patterns": {},
"canonical_id": "",
"strip_prefix": "rules_cc-d66a13e2a01630afcafc4ba411d83e291ecf02bd",
"strip_prefix": "rules_cc-f84656686987ce254481cc33efa3b6645d4254c3",
"type": "tar.gz",
"patches": [],
"patch_tool": "",
Expand All @@ -409,7 +409,7 @@ resolved = [
"tag": "",
"name": "rules_cc",
},
"output_tree_hash": "579c5eed391e6c1e02f4f450b9d99bdc8b86f1a6913b10389e4dbed7ccace6a1",
"output_tree_hash": "400ca6f1331142b6c9922db519cf33d899f9f0c2acd262ac4585d444bf1d0adb",
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: voidstar
version: v1.34.0 # FIXME: 'git'
version: v1.34.1 # FIXME: 'git'
summary: void* casts files onto 2D/3D colored spaces for your mind blowing needs # 79 char long summary
description: |
Usage:
Expand Down
2 changes: 1 addition & 1 deletion voidstar/managers/manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class Manager {
const offset_t woffset = static_cast<offset_t>(sliding_window_offset_);
const offset_t wlength = static_cast<offset_t>(sliding_window_length_);
auto left = indices.begin() + woffset;
if (left < indices.begin()) left = indices.begin();
if (left > indices.end()) left = indices.end() - woffset;
if (left < indices.begin()) left = indices.begin();
auto right = std::min(indices.end(), left + wlength);
if (sliding_window_left_ != &left[0] ||
sliding_window_right_ != &right[0]) {
Expand Down
15 changes: 7 additions & 8 deletions voidstar/size2str.cc
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
#include <cmath>

#include "voidstar/size2str.h"

#include <cmath>

/// 991337 --> "991,337"
std::string size2str(size_t size) {
const auto digits = std::ceil(std::log10(size));
const auto nonits = static_cast<size_t>(std::ceil(digits / 3) -1);
std::string str(static_cast<size_t>(digits)+nonits, '*');
const auto nonits = static_cast<size_t>(std::ceil(digits / 3) - 1);
std::string str(static_cast<size_t>(digits) + nonits, '*');

int written = 0;
for (size_t pos = str.length()-1; pos!=0; pos--) {
for (size_t pos = str.length() - 1; pos != 0; pos--) {
if (written != 0 && written % 3 == 0) {
str[pos] = '_';
written = 0;
continue;
}
str[pos] = static_cast<char>('0' + size%10);
str[pos] = static_cast<char>('0' + size % 10);
size /= 10;
written++;
}
if (size != 0)
str[0] = static_cast<char>('0' + size);
if (size != 0) str[0] = static_cast<char>('0' + size);
return str;
}

0 comments on commit fc05e22

Please sign in to comment.