Skip to content

Occasional malloc error when adding notes #8

Description

@jbmaxwell

I'm noticing a fairly frequent crash when calling add(note:):

SpliqsTool(50382,0x70000ee42000) malloc: *** error for object 0x600000ce9620: pointer being freed was not allocated
SpliqsTool(50382,0x70000eec5000) malloc: Heap corruption detected, free list is damaged at 0x600000cfaed0
*** Incorrect guard value: 1
SpliqsTool(50382,0x70000ee42000) malloc: *** set a breakpoint in malloc_error_break to debug
SpliqsTool(50382,0x70000eec5000) malloc: *** set a breakpoint in malloc_error_break to debug
SpliqsTool(50382,0x70000f4e9000) malloc: Heap corruption detected, free list is damaged at 0x600000ce7fd0
*** Incorrect guard value: 105553129677296
SpliqsTool(50382,0x70000f4e9000) malloc: *** set a breakpoint in malloc_error_break to debug

I'm calling it from an extension I wrote for merging events onto a given channel:

extension MidiNoteTrack {
    func add(notes: [MidiNote], mergeToChannel ch: Int) {
        for note in notes {
            let n = MidiNote(timeStamp: note.timeStamp, duration: note.duration, note: note.note, velocity: note.velocity, channel: UInt8(ch))
            self.add(note: n)
        }
    }
}

I don't see how my function could be causing it (though I obviously won't rule out the possibility) so I thought I'd report it, just in case. I am calling my function from a DispatchQueue.concurrentPerform, which contains a midiData.writeData(to:) call—could that be the problem?

I'm on macOS 10.15.3, Xcode 11.3.1, Swift 5.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions