Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

malloc: *** error for object 0x700002a96090 #2032

Closed
Mladen-K opened this issue Jan 31, 2018 · 7 comments
Closed

malloc: *** error for object 0x700002a96090 #2032

Mladen-K opened this issue Jan 31, 2018 · 7 comments
Labels
repro-needed Issues that cannot be reproduced or miss proper descriptive examples.

Comments

@Mladen-K
Copy link

New Issue Checklist

Bug Report

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint

swiftlint(4532,0x700002a99000) malloc: *** error for object 0x700002a96090: Non-aligned pointer being freed (2)
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

Environment

  • SwiftLint version 0.24.2
  • Installation method used: Homebrew
  • Paste your configuration file:
disabled_rules: # rule identifiers to exclude from running
opt_in_rules: # include rules disabled by default
  - empty_count
included: # paths to include during linting. `--path` is ignored if present.
  - Sources
excluded: # paths to ignore during linting. Takes precedence over `included`.
  - Tests
  - Dependencies
  - Products

# configurable rules
line_length: 110
type_body_length:
  - 300 # warning
  - 400 # error
file_length:
  warning: 500
  error: 1200
type_name:
  min_length: 4 # only warning
  max_length: # warning and error
    warning: 40
    error: 50
  • Which Xcode version are you using: 9.2 (9C40b)

Error is present when root project directory name contains dashes - My-Swift-Project
When dashes are removed - MySwiftProject, linter is not returning error.

@marcelofabri
Copy link
Collaborator

@Mladen-K Can you provide a sample project?

That configuration is not even valid:

/Users/marcelofabri/dev/My-Swift-Project/.swiftlint.yml:3:1: error: scanner: while scanning for the next token in line 3, column 1
found character that cannot start any token:
	- empty_count
^
Could not read configuration file at path '/Users/marcelofabri/dev/My-Swift-Project/.swiftlint.yml': file Configuration.swift, line 145
[1]    90445 abort      swiftlint

After fixing the configuration (replacing tabs for spaces and removing the empty disabled_rules), I was able to run without any issues.

@marcelofabri marcelofabri added the repro-needed Issues that cannot be reproduced or miss proper descriptive examples. label Jan 31, 2018
@jerome-noel
Copy link

There may indeed be a problem with case sensitivity somewhere in the code. Let me explain :

I have a similar issue here on my machine, where swiftlint crashes on free().
To try to provide you guys with some kind of repro, I've stripped down my repo to one single swift file and a valid config, and still had the crash.
I then duplicated the folder, and found that swiftlint was running fine on the duplicated folder.

Then I cloned the SwiftLint repo, and noticed the default arguments for debugging are lint --no-cache.

I re-ran swiftlint on the original folder using lint --no-cache, and it didn't crash anymore.

Then i realised i had recently renamed my repo folder to lowercase. I strongly suspect it's linked

@jerome-noel
Copy link

I also have a crash stack if anyone is interested. It's a crash in the SourceKittenFramework, in JSONOutput.swift:33, deep in JSONSerialization.data ()

@SDGGiesbrecht
Copy link
Contributor

@jerome-noel, do you think this might be related to #2091? (Maybe the old, cached paths are now in the wrong case?)

Is your file system case‐sensitive?

Does the problem go away if you delete the cache? (Unless you have specified a custom location, it would be at ~/Library/Caches/SwiftLint.) Doing so would remove the mis‐cased paths.

@jerome-noel
Copy link

I think it is related to #2091 indeed
No, my file system is case-insensitive
Yes, removing ~/Library/Caches/SwiftLint solves the problem, thanks!

@marcelofabri
Copy link
Collaborator

I was able to reproduce it as well.

// this crashes when options contains [.sortedKeys]
let prettyJSONData = try JSONSerialization.data(withJSONObject: object, options: options)

@marcelofabri
Copy link
Collaborator

Actually, I could isolate it on a playground:

//: Playground - noun: a place where people can play

import Cocoa

let k1 = "[\"/Users/marcelofabri/SwiftLint/source\",[[\"block_based_kvo\",\"warning\"],[\"class_delegate_protocol\",\"warning\"],[\"closing_brace\",\"warning\"],[\"closure_parameter_position\",\"warning\"],[\"colon\",\"warning, flexible_right_spacing: false, apply_to_dictionaries: true\"],[\"comma\",\"warning\"],[\"compiler_protocol_init\",\"warning\"],[\"control_statement\",\"warning\"],[\"custom_rules\",\"\"],[\"cyclomatic_complexity\",\"warning: 10, error: 20, ignores_case_statements: false\"],[\"discarded_notification_center_observer\",\"warning\"],[\"discouraged_direct_init\",\"warning, types: [\"Bundle\", \"Bundle.init\", \"UIDevice\", \"UIDevice.init\"]\"],[\"dynamic_inline\",\"error\"],[\"empty_enum_arguments\",\"warning\"],[\"empty_parameters\",\"warning\"],[\"empty_parentheses_with_trailing_closure\",\"warning\"],[\"fallthrough\",\"warning\"],[\"file_length\",\"warning: 400, error: 1000ignore_comment_only_lines: false\"],[\"for_where\",\"warning\"],[\"force_cast\",\"error\"],[\"force_try\",\"error\"],[\"function_body_length\",\"warning: 40, error: 100\"],[\"function_parameter_count\",\"warning: 5, error: 8\"],[\"generic_type_name\",\"(min_length) w/e: 1/0, (max_length) w/e: 20/1000, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true\"],[\"identifier_name\",\"(min_length) w/e: 3/2, (max_length) w/e: 40/60, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true\"],[\"implicit_getter\",\"warning\"],[\"is_disjoint\",\"warning\"],[\"large_tuple\",\"warning: 2, error: 3\"],[\"leading_whitespace\",\"warning\"],[\"legacy_cggeometry_functions\",\"warning\"],[\"legacy_constant\",\"warning\"],[\"legacy_constructor\",\"warning\"],[\"legacy_nsgeometry_functions\",\"warning\"],[\"line_length\",\"warning: 120, error: 200, ignores urls: false, ignores function declarations: false, ignores comments: false\"],[\"mark\",\"warning\"],[\"multiple_closures_with_trailing_closure\",\"warning\"],[\"nesting\",\"(type_level) w: 1, (statement_level) w: 5\"],[\"notification_center_detachment\",\"warning\"],[\"opening_brace\",\"warning\"],[\"operator_whitespace\",\"warning\"],[\"private_over_fileprivate\",\"warning, validate_extensions: false\"],[\"private_unit_test\",\"[\"private_unit_test\",\"\",\"Unit test marked `private` will not be run by XCTest.\",\"XCTestCase\",\"\",\"warning\"]\"],[\"protocol_property_accessors_order\",\"warning\"],[\"redundant_discardable_let\",\"warning\"],[\"redundant_optional_initialization\",\"warning\"],[\"redundant_string_enum_value\",\"warning\"],[\"redundant_void_return\",\"warning\"],[\"return_arrow_whitespace\",\"warning\"],[\"shorthand_operator\",\"error\"],[\"statement_position\",\"(statement_mode) default, (severity) warning\"],[\"superfluous_disable_command\",\"error\"],[\"switch_case_alignment\",\"warning\"],[\"syntactic_sugar\",\"warning\"],[\"todo\",\"warning\"],[\"trailing_comma\",\"warning, mandatory_comma: false\"],[\"trailing_newline\",\"warning\"],[\"trailing_semicolon\",\"warning\"],[\"trailing_whitespace\",\"warning, ignores_empty_lines: false, ignores_comments: true\"],[\"type_body_length\",\"warning: 200, error: 350\"],[\"type_name\",\"(min_length) w/e: 3/0, (max_length) w/e: 40/1000, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true\"],[\"unneeded_break_in_switch\",\"warning\"],[\"unused_closure_parameter\",\"warning\"],[\"unused_enumerated\",\"warning\"],[\"unused_optional_binding\",\"warning, ignore_optional_try: false\"],[\"valid_ibinspectable\",\"warning\"],[\"vertical_parameter_alignment\",\"warning\"],[\"vertical_whitespace\",\"warning, max_empty_lines: 1\"],[\"void_return\",\"warning\"],[\"weak_delegate\",\"warning\"],[\"xctfail_message\",\"warning\"]]]"

let k2 = "[\"/Users/marcelofabri/SwiftLint/Source\",[[\"block_based_kvo\",\"warning\"],[\"class_delegate_protocol\",\"warning\"],[\"closing_brace\",\"warning\"],[\"closure_parameter_position\",\"warning\"],[\"colon\",\"warning, flexible_right_spacing: false, apply_to_dictionaries: true\"],[\"comma\",\"warning\"],[\"compiler_protocol_init\",\"warning\"],[\"control_statement\",\"warning\"],[\"custom_rules\",\"\"],[\"cyclomatic_complexity\",\"warning: 10, error: 20, ignores_case_statements: false\"],[\"discarded_notification_center_observer\",\"warning\"],[\"discouraged_direct_init\",\"warning, types: [\"Bundle\", \"Bundle.init\", \"UIDevice\", \"UIDevice.init\"]\"],[\"dynamic_inline\",\"error\"],[\"empty_enum_arguments\",\"warning\"],[\"empty_parameters\",\"warning\"],[\"empty_parentheses_with_trailing_closure\",\"warning\"],[\"fallthrough\",\"warning\"],[\"file_length\",\"warning: 400, error: 1000ignore_comment_only_lines: false\"],[\"for_where\",\"warning\"],[\"force_cast\",\"error\"],[\"force_try\",\"error\"],[\"function_body_length\",\"warning: 40, error: 100\"],[\"function_parameter_count\",\"warning: 5, error: 8\"],[\"generic_type_name\",\"(min_length) w/e: 1/0, (max_length) w/e: 20/1000, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true\"],[\"identifier_name\",\"(min_length) w/e: 3/2, (max_length) w/e: 40/60, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true\"],[\"implicit_getter\",\"warning\"],[\"is_disjoint\",\"warning\"],[\"large_tuple\",\"warning: 2, error: 3\"],[\"leading_whitespace\",\"warning\"],[\"legacy_cggeometry_functions\",\"warning\"],[\"legacy_constant\",\"warning\"],[\"legacy_constructor\",\"warning\"],[\"legacy_nsgeometry_functions\",\"warning\"],[\"line_length\",\"warning: 120, error: 200, ignores urls: false, ignores function declarations: false, ignores comments: false\"],[\"mark\",\"warning\"],[\"multiple_closures_with_trailing_closure\",\"warning\"],[\"nesting\",\"(type_level) w: 1, (statement_level) w: 5\"],[\"notification_center_detachment\",\"warning\"],[\"opening_brace\",\"warning\"],[\"operator_whitespace\",\"warning\"],[\"private_over_fileprivate\",\"warning, validate_extensions: false\"],[\"private_unit_test\",\"[\"private_unit_test\",\"\",\"Unit test marked `private` will not be run by XCTest.\",\"XCTestCase\",\"\",\"warning\"]\"],[\"protocol_property_accessors_order\",\"warning\"],[\"redundant_discardable_let\",\"warning\"],[\"redundant_optional_initialization\",\"warning\"],[\"redundant_string_enum_value\",\"warning\"],[\"redundant_void_return\",\"warning\"],[\"return_arrow_whitespace\",\"warning\"],[\"shorthand_operator\",\"error\"],[\"statement_position\",\"(statement_mode) default, (severity) warning\"],[\"superfluous_disable_command\",\"error\"],[\"switch_case_alignment\",\"warning\"],[\"syntactic_sugar\",\"warning\"],[\"todo\",\"warning\"],[\"trailing_comma\",\"warning, mandatory_comma: false\"],[\"trailing_newline\",\"warning\"],[\"trailing_semicolon\",\"warning\"],[\"trailing_whitespace\",\"warning, ignores_empty_lines: false, ignores_comments: true\"],[\"type_body_length\",\"warning: 200, error: 350\"],[\"type_name\",\"(min_length) w/e: 3/0, (max_length) w/e: 40/1000, excluded: [], allowed_symbols: [], validates_start_with_lowercase: true\"],[\"unneeded_break_in_switch\",\"warning\"],[\"unused_closure_parameter\",\"warning\"],[\"unused_enumerated\",\"warning\"],[\"unused_optional_binding\",\"warning, ignore_optional_try: false\"],[\"valid_ibinspectable\",\"warning\"],[\"vertical_parameter_alignment\",\"warning\"],[\"vertical_whitespace\",\"warning, max_empty_lines: 1\"],[\"void_return\",\"warning\"],[\"weak_delegate\",\"warning\"],[\"xctfail_message\",\"warning\"]]]"

let dict = [k1: "test", k2: "test2"]
let data = try? JSONSerialization.data(withJSONObject: dict, options: [.prettyPrinted, .sortedKeys])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repro-needed Issues that cannot be reproduced or miss proper descriptive examples.
Projects
None yet
Development

No branches or pull requests

4 participants