Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

malloc crash “randomly” #78

Closed
rastersize opened this issue Apr 10, 2020 · 4 comments
Closed

malloc crash “randomly” #78

rastersize opened this issue Apr 10, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@rastersize
Copy link
Contributor

Hey!

When trying to generate docs for the libraries in an app I’m working on I keep running into malloc crashes. This happens for different libraries for different runs. Both when using the markdown and HTML formats.

Basically I run this command for a number of modules:

swift doc generate \
  --output Libraries/$module_name \
  --module-name $module_name \
  --output artifacts/docs/API/$module_name \
  [--format html]

The errors I see are:

swift-doc(44797,0x70000879f000) malloc: Double free of object 0x7ff8b6d11c00
swift-doc(44797,0x70000879f000) malloc: *** set a breakpoint in malloc_error_break to debug
swift-doc(50645,0x700003d39000) malloc: *** error for object 0x7ff087124ba0: pointer being freed was not allocated
swift-doc(50645,0x700003d39000) malloc: *** set a breakpoint in malloc_error_break to debug

For now I’ve worked around it by retrying the swift doc operation on failures. Which seems to generate all docs.


Side note, I tried to build the project in Xcode to help debug the issue. Unfortunately Xcode (11.4 (11E146)) fails to build with an error:

Swift Compiler Error Group
/Applications/Xcode-1140.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/libxml2/libxml/module.modulemap:1:8: Redefinition of module 'libxml2'
/Users/.../swift-doc/.build/checkouts/Markup/Modules/module.modulemap:1:8: Previously defined here

I can file a separate issue for this if you want?

@mattt mattt added the bug Something isn't working label Apr 10, 2020
@mattt
Copy link
Contributor

mattt commented Apr 10, 2020

Thanks for reporting this, @rastersize. I've seen this come up in development as well. I'm almost certain that the root cause of this is our implementation of parallelMap. Unfortunately, I've also been unable to leverage Xcode's debugging stack (#60), and am left to guess at why this is randomly failing.

@kean
Copy link
Contributor

kean commented Apr 11, 2020

The crash is in Interface.swift:

for `extension` in extensionsByExtendedType[symbol.id.description] ?? [] {
    inheritedTypeNames.formUnion(`extension`.inheritance)
}

The problem is that extensionsByExtendedType is lazy and lazy isn't thread safe. This makes Interface non thread-safe.

@mattt
Copy link
Contributor

mattt commented May 13, 2020

This should be fixed by #99.

@rastersize I'm working to cut a new release (1.0.0-beta.3) this week, but you're welcome to try the latest in master in the meantime.

@mattt mattt closed this as completed May 13, 2020
@rastersize
Copy link
Contributor Author

Great news! I’ll see if I have time to try it out later this week.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants