Skip to content

Commit d0721ec

Browse files
authored
Merge pull request #3074 from perspective-dev/fix-segfault-2
Fix `View::expand`, `View::collapse` unlocked server section
2 parents c86b9a6 + 788c53a commit d0721ec

5 files changed

Lines changed: 40 additions & 23 deletions

File tree

packages/viewer-d3fc/src/ts/axis/valueFormatter.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ export const getValueFormatterForRange = (min: number, max: number) => {
1818
let precision = Math.ceil(Math.abs(Math.log10(max - min))) + 1;
1919

2020
return (d: number) => {
21-
return Math.abs(d) >= SI_MIN
22-
? d3.format(".3s")(d)
23-
: Number.isInteger(d)
24-
? d3.format(",.0f")(d)
25-
: d3.format(`,.${precision}f`)(d);
21+
try {
22+
return Math.abs(d) >= SI_MIN
23+
? d3.format(".3s")(d)
24+
: Number.isInteger(d)
25+
? d3.format(",.0f")(d)
26+
: d3.format(`,.${precision}f`)(d);
27+
} catch (e) {
28+
console.warn(e);
29+
return "<err>";
30+
}
2631
};
2732
};

rust/perspective-python/perspective/tests/multi_threaded/test_multi_threaded.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def run_perspective():
160160
thread2.join()
161161

162162
def test_concurrent_view_creation_with_updates_are_threadsafe(self):
163+
global running
163164
s = Server()
164165
schema = {
165166
"a": "string",

rust/perspective-server/cpp/perspective/src/cpp/server.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,19 @@ make_context(
130130

131131
auto pool = table->get_pool();
132132
auto gnode = table->get_gnode();
133+
if (row_pivot_depth > -1) {
134+
ctx1->set_depth(row_pivot_depth - 1);
135+
} else {
136+
ctx1->set_depth(row_pivots.size());
137+
}
138+
133139
pool->register_context(
134140
gnode->get_id(),
135141
name,
136142
ONE_SIDED_CONTEXT,
137143
reinterpret_cast<std::uintptr_t>(ctx1.get())
138144
);
139145

140-
if (row_pivot_depth > -1) {
141-
ctx1->set_depth(row_pivot_depth - 1);
142-
} else {
143-
ctx1->set_depth(row_pivots.size());
144-
}
145-
146146
return ctx1;
147147
}
148148

@@ -193,13 +193,6 @@ make_context(
193193
ctx2->column_sort_by(col_sortspec);
194194
}
195195

196-
pool->register_context(
197-
gnode->get_id(),
198-
name,
199-
TWO_SIDED_CONTEXT,
200-
reinterpret_cast<std::uintptr_t>(ctx2.get())
201-
);
202-
203196
if (row_pivot_depth > -1) {
204197
ctx2->set_depth(t_header::HEADER_ROW, row_pivot_depth - 1);
205198
} else {
@@ -212,6 +205,13 @@ make_context(
212205
ctx2->set_depth(t_header::HEADER_COLUMN, column_pivots.size());
213206
}
214207

208+
pool->register_context(
209+
gnode->get_id(),
210+
name,
211+
TWO_SIDED_CONTEXT,
212+
reinterpret_cast<std::uintptr_t>(ctx2.get())
213+
);
214+
215215
return ctx2;
216216
}
217217

rust/perspective-server/cpp/perspective/src/cpp/view.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,12 +1448,18 @@ View<t_ctx0>::expand(std::int32_t ridx, std::int32_t row_pivot_length) {
14481448
template <>
14491449
t_index
14501450
View<t_ctx1>::expand(std::int32_t ridx, std::int32_t row_pivot_length) {
1451+
#ifdef PSP_PARALLEL_FOR
1452+
PSP_WRITE_LOCK(*get_lock())
1453+
#endif
14511454
return m_ctx->open(ridx);
14521455
}
14531456

14541457
template <>
14551458
t_index
14561459
View<t_ctx2>::expand(std::int32_t ridx, std::int32_t row_pivot_length) {
1460+
#ifdef PSP_PARALLEL_FOR
1461+
PSP_WRITE_LOCK(*get_lock())
1462+
#endif
14571463
if (m_ctx->unity_get_row_depth(ridx) < t_uindex(row_pivot_length)) {
14581464
return m_ctx->open(t_header::HEADER_ROW, ridx);
14591465
}
@@ -1475,12 +1481,18 @@ View<t_ctx0>::collapse(std::int32_t ridx) {
14751481
template <>
14761482
t_index
14771483
View<t_ctx1>::collapse(std::int32_t ridx) {
1484+
#ifdef PSP_PARALLEL_FOR
1485+
PSP_WRITE_LOCK(*get_lock())
1486+
#endif
14781487
return m_ctx->close(ridx);
14791488
}
14801489

14811490
template <>
14821491
t_index
14831492
View<t_ctx2>::collapse(std::int32_t ridx) {
1493+
#ifdef PSP_PARALLEL_FOR
1494+
PSP_WRITE_LOCK(*get_lock())
1495+
#endif
14841496
return m_ctx->close(t_header::HEADER_ROW, ridx);
14851497
}
14861498

tools/scripts/bench.mjs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ import sh from "./sh.mjs";
1515
import { get_scope } from "./sh_perspective.mjs";
1616

1717
dotenv.config({ path: "./.perspectiverc", quiet: true });
18-
1918
const scope = get_scope();
20-
if (scope.includes("perspective")) {
21-
sh`pnpm run --recursive --filter perspective-bench bench_js`.runSync();
22-
} else if (scope.includes("perspective-python")) {
23-
sh`pnpm run --recursive --filter perspective-bench bench_python`.runSync();
19+
if (scope.includes("client")) {
20+
sh`pnpm run --recursive --filter bench bench_js`.runSync();
21+
} else if (scope.includes("python")) {
22+
sh`pnpm run --recursive --filter bench bench_python`.runSync();
2423
}

0 commit comments

Comments
 (0)