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

Segmentation fault with nested configs and autocorrect. #368

Closed
scottrhoyt opened this issue Jan 14, 2016 · 14 comments
Closed

Segmentation fault with nested configs and autocorrect. #368

scottrhoyt opened this issue Jan 14, 2016 · 14 comments
Labels
bug Unexpected and reproducible misbehavior.

Comments

@scottrhoyt
Copy link
Contributor

Not 100% sure on this one. Was getting a segmentation fault using autocorrect, and I removed enable_nesting_configs: true and it went away. There might be something to investigate here.

@scottrhoyt scottrhoyt added the bug Unexpected and reproducible misbehavior. label Jan 14, 2016
@nicolai86
Copy link
Contributor

@scottrhoyt can you enable the option use_nested_configs again and post the stacktrace?

@mlennon3
Copy link

I'm getting the same behavior..

$# swiftlint.yml has use_nested_configs: true
$ swiftlint version
0.6.0
$ swiftlint autocorrect
Loading configuration from '.swiftlint.yml'
Correcting Swift files in current working directory
Correcting 'myfile.swift' (1/68)
Segmentation fault: 11

when remove use_nested_configs: true, autocorrect works correctly. I'm on OSX 10.10.5.

@jpsim
Copy link
Collaborator

jpsim commented Jan 18, 2016

@mlennon3 how can we reproduce that? What about your configuration makes this crash? Can you build & run SwiftLint from Xcode so that LLDB shows where this is crashing?

Maybe if you shared the contents of your config files and their layout in the file system, we'd have more information to go on?

@mlennon3
Copy link

I created a shell project called nestedLint, which is an xcodeproj, and has no swift files besides the ones provided by xcode (AppDelegate, etc). I have:

$ pwd
~/tmp/nestedLint
$ ls -a
.                    ..                   .swiftlint.yml       myDir                nestedLint           nestedLint.xcodeproj
$ ls -a myDir/
.              ..             .swiftlint.yml
$ cat .swiftlint.yml
use_nested_configs: true
$ cat myDir/.swiftlint.yml
$
$ swiftlint autocorrect
Loading configuration from '.swiftlint.yml'
Correcting Swift files in current working directory
Correcting 'AppDelegate.swift' (1/2)
Segmentation fault: 11

@jpsim
Copy link
Collaborator

jpsim commented Jan 21, 2016

Hmm, I can't reproduce it like that:

$ cd /tmp
$ mkdir topdir
$ cd topdir
$ echo "use_nested_configs: true" > .swiftlint.yml
$ mkdir nested
$ touch nested/.swiftlint.yml nested/file.swift
$ swiftlint
Loading configuration from '.swiftlint.yml'
Linting Swift files in current working directory
Linting 'file.swift' (1/1)
/tmp/topdir/nested/file.swift:1: warning: Trailing Newline Violation: Files should have a single trailing newline. (trailing_newline)
Done linting! Found 1 violation, 0 serious in 1 file.
$ swiftlint version
0.6.0

@mlennon3
Copy link

Did you try $swiftlint autocorrect ?

@jpsim
Copy link
Collaborator

jpsim commented Jan 21, 2016

Yes

@mlennon3
Copy link

OK so if I do the steps you have done there, i get no segfault.

If however, I don't mkdir topdir but instead create a project in Xcode called topdir, and do the rest as you have it written, I get segfault 11

@jpsim
Copy link
Collaborator

jpsim commented Jan 21, 2016

Still no luck:

$ cat .swiftlint.yml
use_nested_configs: true
$ cat LintSegFault/.swiftlint.yml
$ tree -a
.
├── .swiftlint.yml
├── LintSegFault
│   ├── .swiftlint.yml
│   ├── AppDelegate.swift
│   ├── Assets.xcassets
│   │   └── AppIcon.appiconset
│   │       └── Contents.json
│   ├── Base.lproj
│   │   ├── LaunchScreen.storyboard
│   │   └── Main.storyboard
│   ├── Info.plist
│   └── ViewController.swift
└── LintSegFault.xcodeproj
    ├── project.pbxproj
    └── project.xcworkspace
        └── contents.xcworkspacedata

6 directories, 10 files
$ swiftlint autocorrect
swiftlint autocorrect
Loading configuration from '.swiftlint.yml'
Correcting Swift files in current working directory
Correcting 'AppDelegate.swift' (1/2)
/tmp/LintSegFault/LintSegFault/AppDelegate.swift:45 Corrected Trailing Newline
Correcting 'ViewController.swift' (2/2)
/tmp/LintSegFault/LintSegFault/ViewController.swift:24 Corrected Trailing Newline
Done correcting 2 files!

@mlennon3
Copy link

Hm. Well I'm on XCode Version 7.2 (7C68)...

@jpsim
Copy link
Collaborator

jpsim commented Jan 21, 2016

$ xcodebuild -version
Xcode 7.2
Build version 7C68

@mlennon3
Copy link

OK here's a difference:

~/tmp/topdir
$ tree -a
.
├── .swiftlint.yml
├── nested
│   ├── .swiftlint.yml
│   └── file.swift
├── topdir
│   ├── AppDelegate.swift
│   ├── Assets.xcassets
│   │   └── AppIcon.appiconset
│   │       └── Contents.json
│   ├── Base.lproj
│   │   ├── LaunchScreen.storyboard
│   │   └── Main.storyboard
│   ├── Info.plist
│   └── ViewController.swift
└── topdir.xcodeproj
    ├── project.pbxproj
    ├── project.xcworkspace
    │   ├── contents.xcworkspacedata
    │   └── xcuserdata
    │       └── mslennon.xcuserdatad
    │           └── UserInterfaceState.xcuserstate
    └── xcuserdata
        └── mslennon.xcuserdatad
            └── xcschemes
                ├── topdir.xcscheme
                └── xcschememanagement.plist

This is like more how we have our directories structured in our real app than the example you gave..

@jpsim
Copy link
Collaborator

jpsim commented Jan 21, 2016

Aha! That last directory structure you shared was key in reproducing this:

$ mkdir topdir
$ cd topdir
$ mkdir one two
$ touch one/.swiftlint.yml two/two.swift
$ echo "use_nested_configs: true" > .swiftlint.yml
$ swiftlint autocorrect
Loading configuration from '.swiftlint.yml'
Correcting Swift files in current working directory
Correcting 'two.swift' (1/1)
[1]    51441 segmentation fault  swiftlint autocorrect

Thanks for your help, I think we can take it from here.

@mlennon3
Copy link

Great, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
Development

No branches or pull requests

4 participants