iainctduncan/scheme-for-max

Max crashes intermittently when running s4m "scan"

Closed this issue · 10 comments

Environment: Intel Mac Mini, MacOS 11.6, Max 8.1.11, s4m 0.3.0-rc4

I'm running through "Scripting and Live-Coding Max with Scheme for Max - On-demand" on Musichackspace and built the sequencer. Everything runs nicely except that every few times I do a "reboot" Max will crash. The top of the stack trace varies but s4m_scan+222 is always a few calls back and the error is usually an illegal instruction. Anecdotally, when I commented out a couple of lines of code referencing the multisliders by scripting name the crashes became much less frequent.

Happy to provide the Max patch and .scm file if that's useful, or do anything else I can to help. I have gone back to the 0.2.0 beta and the crashes have gone away.

Cheers,
Rick.

Hi Rick, thanks for reporting this, and welcome! I was hoping to do a 0.3 release, but you catching this means there is still work to do. On my machine, I don't get any random crashes at all anymore, so there's something definitely wrong. Are you a C programmer? Just thinking about how best to tackle this, given I don't have OS 11 on here (and want to leave this machine alone as I'll probably get a M1 in the new year for dev on the new chips and OS 11).

One thing I could try is building a version of 0.3 removing the automatic scan that happens on reset to see if you get better results from running scan separately. I put it in there for convenience, but perhaps that was a mistake, and we just need some alternate convenience helper for scanning post reset.

The line to comment out would be line 645, where scan is called inside s4m_reset(). I'm thinking a possible fix is to finish reset and put a message to self on the scheduler to call scan on the next pass. I did notice in previous builds that having too many things happen in a reset call can be problematic. I need to attend to some work stuff for a bit but can make you builds to help test this in an hour or so.

Hi Rick, can you try this build, all it does is comment out the call to scan in the reset function. If this fixes your issue, I should be able to make a proper fix. thanks!

https://github.com/iainctduncan/scheme-for-max/releases/tag/issue-130-fix-1

Hi Iain, I only had time to test it quickly this morning but I couldn't get it to fail in a few minutes of hammering it and the older version would crash quite quickly. Thanks very much!

For future reference, I am a C programmer albeit a very rusty one. I last did serious C programming on UNIX superminis :)

ok cool, that's good to know (though strange that the same thing didn't happen to me!) I will see if I can cook up a less optimistic version of auto scanning and let you know when that can be tested. thanks Rick!

Hi Iain,

FYI, I tried 0.3.0-rc4 on a Mac Mini M1 2020/MacOS 11.6/Max 8.1.11 and it crashes like it does on my M1 Intel. I then tried the 130-fix-1 version and it works reliably.

Also FYI, I tried upgrading to Max 8.2.1 and s4m won't run at all - Max console says "s4m: could not load due to incorrect architecture." I don't really need Max 8.2.1 at present so I just went back to 8.1.11 for now. Perhaps when I have some more time with the M1 Mini I'll have a go at building a M1 native binary from source. I have no idea how to do that but given time I can probably figure it out :)

Cheers,
Rick.

Thanks Rick, that's super helpful. And if you want to help later with builds, that would be great too. I would be happy to help you get going.

I just put up a text mxo with scan moved to after s7_init. If that doesn't do it, we can schedule the scan call on the next scheduler pass

I reinstalled the rc4 version and confirmed it still crashed on my Mac Mini M1. Then I installed the issue-130-fix-2 OSX binary and it did not crash after many attempts. Looks good, thanks Iain!

Thanks for the thorough testing Rick, much appreciated! We are good for 0.3, woot! Just finished updating the help file. :-)