Skip to content

Commit 3c12e26

Browse files
committed
fix
Signed-off-by: Joe Isaacs <[email protected]>
1 parent 0c9af75 commit 3c12e26

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

vortex-array/src/array/visitor.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
use std::fmt::Formatter;
5-
use std::ops::Deref;
65
use std::sync::Arc;
76

87
use vortex_buffer::ByteBuffer;
@@ -145,11 +144,10 @@ pub trait ArrayChildVisitor<'a> {
145144
// * is_nullable & has_validity => Validity::Array (or Validity::AllInvalid)
146145
// * is_nullable & !has_validity => Validity::AllValid
147146
// * !is_nullable => Validity::NonNullable
148-
let constant = ConstantArray::new(false, len);
149-
// SAFETY: We extend the lifetime of the dynamically-constructed constant array
150-
// to 'a. This is safe because the visitor will not retain references beyond this call,
151-
// and the array lives for the scope of this function.
152-
let constant_ref: &'a dyn Array = unsafe { std::mem::transmute(constant.deref()) };
147+
let constant = ConstantArray::new(false, len).to_array();
148+
// TODO: This leaks memory but fixes the dangling pointer bug that caused SIGSEGV
149+
let leaked: &'static ArrayRef = Box::leak(Box::new(constant));
150+
let constant_ref: &'a dyn Array = leaked.as_ref();
153151
self.visit_child("validity", constant_ref)
154152
}
155153
Validity::Array(array) => {

0 commit comments

Comments
 (0)