Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !6725

[Objective-C] Fix thread-safety in template

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/michalcichon/fix-objc-template into master Jun 20, 2020
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 3

Created by: michalcichon

  • A static set needs a static lock or we get multiple locks if the class is inherited
  • If this fix is not included and SWGObject is accessed from a second thread then we get EXC_BAD_ACCESS error (crash)

Example crash:

Crashed: asyncRealm
0  libobjc.A.dylib                0x180f82088 objc_msgSend + 8
1  CoreFoundation                 0x1811e400c -[__NSSetM containsObject:] + 180
2  MyApp                          0x10094fc28 -[SWGObject initWithDictionary:error:] + 20 (SWGObject.m:20)
3  MyApp                          0x100e019e4 -[JSONModel __importDictionary:withKeyMapper:validation:error:] + 4310850020
4  MyApp                          0x100e00a28 -[JSONModel initWithDictionary:error:] + 4310845992
5  MyApp                          0x10094fcac -[SWGObject initWithDictionary:error:] + 29 (SWGObject.m:29)
6  MyApp                          0x100e019e4 -[JSONModel __importDictionary:withKeyMapper:validation:error:] + 4310850020
7  MyApp                          0x100e00a28 -[JSONModel initWithDictionary:error:] + 4310845992
8  MyApp                          0x10094fcac -[SWGObject initWithDictionary:error:] + 29 (SWGObject.m:29)
9  MyApp                          0x100e00700 -[JSONModel initWithData:error:] + 4310845184
10 MyApp                          0x100e0088c -[JSONModel initWithString:usingEncoding:error:] + 4310845580
11 MyApp                          0x100e007c4 -[JSONModel initWithString:error:] + 4310845380
12 MyApp                          0x100aa3138 specialized static PostPersistence.deleteOldPosts(realm:) + 4307317048 (PostPersistence.swift:4307317048)
13 MyApp                          0x100aa2238 closure #1 in static PostPersistence.persistPostsAsync(_:) + 23 (PostPersistence.swift:23)
14 MyApp                          0x1009e9840 thunk for @escaping @callee_guaranteed () -> () + 4306556992 (<compiler-generated>:4306556992)
15 libdispatch.dylib              0x180f2a610 _dispatch_call_block_and_release + 24
16 libdispatch.dylib              0x180f2b184 _dispatch_client_callout + 16
17 libdispatch.dylib              0x180f08710 _dispatch_lane_serial_drain$VARIANT$armv81 + 564
18 libdispatch.dylib              0x180f09128 _dispatch_lane_invoke$VARIANT$armv81 + 400
19 libdispatch.dylib              0x180f1243c _dispatch_workloop_worker_thread + 576
20 libsystem_pthread.dylib        0x180f7af88 _pthread_wqthread + 276
21 libsystem_pthread.dylib        0x180f7dad4 start_wqthread + 8

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/config/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/michalcichon/fix-objc-template