Skip to content

Commit 6aadbd8

Browse files
committed
Remove warnings from rust loader, remove tests that break with sanitizers from rust, and change compile options in address sanitizer.
1 parent 2ed5fbb commit 6aadbd8

File tree

6 files changed

+25
-18
lines changed

6 files changed

+25
-18
lines changed

.github/workflows/macos-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
os: [macos-13, macos-14, macos-15]
25+
os: [macos-14, macos-15-intel, macos-15]
2626
options: [
2727
{build: debug, sanitizer: without-sanitizer},
2828
{build: debug, sanitizer: address-sanitizer},

cmake/CompileOptions.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ elseif(OPTION_BUILD_ADDRESS_SANITIZER AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR
131131
"LSAN_OPTIONS=verbosity=1:log_threads=1:print_suppressions=false:suppressions=${CMAKE_SOURCE_DIR}/source/tests/sanitizer/lsan.supp"
132132

133133
# Specify handle_segv=0 and detect_leaks=0 for the JVM (https://blog.gypsyengineer.com/en/security/running-java-with-addresssanitizer.html)
134-
# "ASAN_OPTIONS=handle_segv=0:symbolize=1:alloc_dealloc_mismatch=0:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:fast_unwind_on_malloc=0"
134+
# "ASAN_OPTIONS=handle_segv=0:symbolize=1:alloc_dealloc_mismatch=1:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:fast_unwind_on_malloc=0"
135135

136136
# TODO: We should document each flag why is it used, because now we do not know what runtime has each requirement and why.
137137
# Another option should be to separate by runtimes and only set up them on the ASAN tests that require them,
138138
# because we do not need to disable all features on all tests, this may hide bugs in the core library for example.
139139

140140
# Specify use_sigaltstack=0 as CoreCLR uses own alternate stack for signal handlers (https://github.com/swgillespie/coreclr/commit/bec020aa466d08e49e007d0011b0e79f8f7c7a62)
141-
"ASAN_OPTIONS=use_sigaltstack=0:symbolize=1:alloc_dealloc_mismatch=0:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:fast_unwind_on_malloc=0"
141+
"ASAN_OPTIONS=use_sigaltstack=0:symbolize=1:alloc_dealloc_mismatch=1:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:fast_unwind_on_malloc=0"
142142
)
143143
set(SANITIZER_COMPILE_DEFINITIONS
144144
"__ADDRESS_SANITIZER__=1"

source/loaders/rs_loader/rust/compiler/src/lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#![feature(rustc_private)]
22
#![feature(once_cell)]
3-
// allow us to match on Box<T>s:
3+
// Allow us to match on Box<T>s:
44
#![feature(box_patterns)]
55
#![feature(let_else)]
66
#![feature(iter_zip)]
7-
// allow us to get file prefix
7+
// Allow us to get file prefix
88
#![feature(path_file_prefix)]
99
extern crate rustc_ast;
1010
extern crate rustc_ast_pretty;
@@ -329,7 +329,7 @@ pub enum FunctionType {
329329
Ptr,
330330
Null,
331331
Complex,
332-
This, // self in struct method
332+
This, // Self in struct method
333333
}
334334

335335
impl fmt::Display for FunctionType {
@@ -374,11 +374,11 @@ pub struct Attribute {
374374
pub struct Class {
375375
name: String,
376376
constructor: Option<Function>,
377-
destructor: Option<Function>, // maybe we don't need destructor. just drop the variable
377+
destructor: Option<Function>, // TODO: Maybe we don't need destructor, just drop the variable (review)
378378
methods: Vec<Function>,
379379
static_methods: Vec<Function>,
380380
attributes: Vec<Attribute>,
381-
// static_attributes: Vec<Attribute>, // we don't handle static attrs in rust
381+
// static_attributes: Vec<Attribute>, // We don't handle static attrs in rust
382382
}
383383
#[derive(Clone, Debug)]
384384
pub struct CompilerState {
@@ -430,28 +430,28 @@ impl CompilerCallbacks {
430430
.expect("Unable to get global ctxt")
431431
.peek_mut()
432432
.enter(|ctxt| {
433-
// since we are loading a package, input_path should be lib<crate_name>.rlib
433+
// Since we are loading a package, input_path should be lib<crate_name>.rlib
434434
let crate_name = &self
435435
.source
436436
.input_path
437437
.file_prefix()
438438
.expect("Unable to get file prefix.")
439439
.to_str()
440440
.expect("Unable to cast OsStr to str")[3..];
441-
// find our krate
441+
// Find our crate
442442
let crate_num = krates
443443
.iter()
444444
.find(|&&x| {
445445
ctxt.crate_name(x) == rustc_span::Symbol::intern(crate_name)
446446
})
447447
.or_else(|| krates.iter().next())
448448
.expect("unable to find crate");
449-
// parse public functions and structs
449+
// Parse public functions and structs
450450
for child in ctxt.item_children(crate_num.as_def_id()) {
451451
let Export {
452452
ident, res, vis, ..
453453
} = child;
454-
// skip non-public items
454+
// Skip non-public items
455455
if !matches!(vis, Visibility::Public) {
456456
continue;
457457
}
@@ -499,7 +499,7 @@ impl CompilerCallbacks {
499499
_ => {}
500500
}
501501
}
502-
// after parsing all structs, parse tarit implementations.
502+
// After parsing all structs, parse tarit implementations
503503
for trait_impl in ctxt.all_trait_implementations(*crate_num) {
504504
use rustc_middle::ty::fast_reject::SimplifiedTypeGen::AdtSimplifiedType;
505505
if let Some(AdtSimplifiedType(def_id)) = trait_impl.1 {
@@ -710,7 +710,7 @@ impl<'a> visit::Visitor<'a> for ItemVisitor {
710710
let name = item.ident.to_string();
711711
match &item.kind {
712712
rustc_ast::AssocItemKind::Fn(box rustc_ast::Fn { sig, .. }) => {
713-
// function has self in parameters
713+
// Function has self in parameters
714714
if sig.decl.has_self() {
715715
match impl_kind {
716716
ImplKind::Drop => {
@@ -721,7 +721,7 @@ impl<'a> visit::Visitor<'a> for ItemVisitor {
721721
}
722722
}
723723
} else {
724-
// static method
724+
// Static method
725725
match &sig.decl.output {
726726
rustc_ast::FnRetTy::Ty(p) => match &**p {
727727
rustc_ast::Ty { kind, .. } => match kind {

source/loaders/rs_loader/rust/compiler/src/wrapper/class.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(dead_code)] // Disable warnings for unused code
2+
13
use std::any::*;
24
use std::cell::Ref;
35
use std::cell::RefCell;

source/ports/node_port/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ set(node_port_test_exec "${node_port_test}_executable")
226226

227227
# TODO: Since MacOS 14 with ARM64, it does not support well NodeJS executable with preloaded sanitizers
228228
# The NodeJS initalization fails with: Node Loader failed to hook napi_register_module_v1
229-
if(APPLE)
229+
if(PROJECT_OS_FAMILY STREQUAL macos)
230230
# Check if NodeJS is compiled with Address Sanitizer
231231
if(OPTION_BUILD_ADDRESS_SANITIZER)
232232
check_asan_executable("${NodeJS_EXECUTABLE}" NodeJS_ASAN)
@@ -246,6 +246,11 @@ if(APPLE)
246246
endif()
247247
endif()
248248

249+
# Address sanitizer does not work with Rust on Linux in NodeJS executable test
250+
if(PROJECT_OS_LINUX AND OPTION_BUILD_ADDRESS_SANITIZER AND OPTION_BUILD_LOADERS_RS)
251+
set(TESTS_ENVIRONMENT_VARIABLES_RS)
252+
endif()
253+
249254
message(STATUS "Test ${node_port_test_exec}")
250255

251256
add_test(NAME ${node_port_test_exec}

source/tests/metacall_python_port_test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ add_test(NAME ${target}
135135
COMMAND $<TARGET_FILE:${target}>
136136
)
137137

138-
# Enable rust test if it is built
139-
if(OPTION_BUILD_LOADERS_RS)
138+
# Enable rust test if it is built (address sanitizer does not work with Rust on Linux)
139+
if(OPTION_BUILD_LOADERS_RS AND NOT (OPTION_BUILD_ADDRESS_SANITIZER AND PROJECT_OS_LINUX))
140140
set(RS_DEPENDENCY rs_loader)
141141
set(TESTS_ENVIRONMENT_VARIABLES_RS "OPTION_BUILD_LOADERS_RS=1")
142142
endif()

0 commit comments

Comments
 (0)