Sanitizer fixes (#2280)

This commit is contained in:
Tim Sylvester
2024-04-29 06:33:08 -07:00
committed by GitHub
parent 6ebbc3dd6a
commit cd9727b06f
14 changed files with 85 additions and 37 deletions

View File

@@ -123,6 +123,7 @@ apple_xcframework(
data = glob([
"resources/*.lproj/**",
"resources/*.xcassets/**",
"resources/metal-cpp-ignores.txt",
]),
infoplists = ["info_plist"],
ios = {
@@ -159,6 +160,7 @@ apple_resource_bundle(
resources = glob([
"resources/*.lproj/**",
"resources/*.xcassets/**",
"resources/metal-cpp-ignores.txt",
]),
visibility = ["//visibility:public"],
)

View File

@@ -3,14 +3,30 @@
#import "MBXAppDelegate.h"
#import "MBXViewController.h"
#if __has_feature(undefined_behavior_sanitizer) || defined(__SANITIZE_UNDEFINED_BEHAVIOR__)
#import "sanitizer/ubsan_interface.h"
const char* __ubsan_default_options(void) {
static char default_opts[2 * PATH_MAX];
NSString* path = [[NSBundle bundleForClass:[MBXAppDelegate class]] pathForResource:@"metal-cpp-ignores" ofType:@"txt" inDirectory:@"Mapbox.bundle"];
NSString* opts = @"print_stacktrace=1,halt_on_error=1,report_error_type=1,verbosity=0"; // add ',help=1' to see available options
if (path) {
opts = [opts stringByAppendingFormat:@",suppressions=%@", path];
}
NSLog(@"Using ubsan options: %@", opts);
bzero(default_opts, sizeof(default_opts));
strncpy(default_opts, [opts UTF8String], sizeof(default_opts) - 1);
return default_opts;
}
#endif
@interface MBXAppDelegate()
@end
@implementation MBXAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#ifndef MLN_LOGGING_DISABLED
[MLNLoggingConfiguration sharedConfiguration].loggingLevel = MLNLoggingLevelFault;
#endif

View File

@@ -0,0 +1,7 @@
# metal-cpp uses calls through null pointers
# Note that the code must be compiled with `-fsanitize-recover=null` for this to work.
null:vendor/metal-cpp/*
# `NS::String*` implicit cast to `NS::Object*` in Context::createProgram
alignment:src/mbgl/mtl/context.cpp