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

Comments

Projects
None yet
4 participants
@Mladen-K

Mladen-K commented Jan 31, 2018

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

This comment has been minimized.

Collaborator

marcelofabri commented Jan 31, 2018

@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.

@jerome-noel

This comment has been minimized.

jerome-noel commented Mar 12, 2018

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

This comment has been minimized.

jerome-noel commented Mar 12, 2018

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

This comment has been minimized.

Contributor

SDGGiesbrecht commented Mar 12, 2018

@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

This comment has been minimized.

jerome-noel commented Mar 12, 2018

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

This comment has been minimized.

Collaborator

marcelofabri commented Mar 23, 2018

I was able to reproduce it as well.

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

This comment has been minimized.

Collaborator

marcelofabri commented Mar 23, 2018

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])

marcelofabri added a commit to marcelofabri/SwiftLint that referenced this issue Mar 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment