COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 07-18-2017, 02:56 AM   #1
Anomaly
Human being with feelings
 
Anomaly's Avatar
 
Join Date: Sep 2007
Posts: 642
Default Strange Crashing issue

Greetings,

I'm experiencing very curious crashing problem with one of my projects. I seem to lack the required understanding to resolve this issue.

The crash is happening when I EXIT the host running this specific dll. The crash frequency is about 33% of all exits.
The error message says:

Faulting application name: reaper.exe, version: 5.4.0.0, time stamp: 0x58d4503b
Faulting module name: ntdll.dll, version: 6.1.7601.18247, time stamp: 0x521ea8e7
Exception code: 0xc0000005
Fault offset: 0x0003332f

I have seen these Reaper exit & ntdll.dll crashes quite a lot with other vst plugins too. So in this light I was wondering if this issue is with Reaper, instead of my project.

However, when I debug the crash with VS, it points to IPlugVST.cpp line 366:

case effClose:
{
lock.Destroy();
DELETE_NULL(_this);
return 0; <<--------------- Stopped at exception
}

I have checked and re-checked and yet again checked that ALL objects I create with "new" are being deleted properly. So I don't think this is the cause.

To make thing even more bizarre, I noticed that this crash might have interaction with arrays I'm using. There are about 12 small arrays in this particular project (acting as delay lines). When I completely remove them, the exit crash seems to go away.
BUT ALSO: When I INCREASE the size of each array to something like 20000 each (instead of default 1000), the crashing seems to go away too!!???

I have tested arrays on heap, arrays on stack and vectors. They all behave the exact same way with this issue.

Code:
class StaticDelay
{
public:
	StaticDelay() {}
	~StaticDelay() {}

	void Init(int length_spl) {
		length = std::min(length_spl, 1000);
		sindex = 0;
	};

	double Process(double input) {
		sloop[sindex] = input;
		sindex >= length ? sindex = 0 : sindex++;
		return sloop[sindex];
	};
	
private:
	int sindex = 0, length = 0;
	double sloop[1000] = {};
};
In the end I'm not even sure the arrays are the cause of this. I'm using the same methods with my other projects too, and they have not been crashing this way. Only this particular project.

So, I'm open to suggestions if possible how to try to resolve this issue?
Thanks for reading!
__________________
___________________________
Sonic Anomaly | free JSFX & VST Plugins

Last edited by Anomaly; 07-18-2017 at 03:45 AM.
Anomaly is offline   Reply With Quote
Old 07-18-2017, 06:35 AM   #2
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 654
Default

It is hard to tell what is going on. Crash on exit could happen if you try to delete object that has already been deleted, so watch for this. Also, you should delete arrays only if you used "new" to create it. Also delete arrays with "delete[]".
Youlean is offline   Reply With Quote
Old 07-18-2017, 11:12 PM   #3
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by Anomaly View Post
To make thing even more bizarre, I noticed that this crash might have interaction with arrays I'm using. There are about 12 small arrays in this particular project (acting as delay lines). When I completely remove them, the exit crash seems to go away.
BUT ALSO: When I INCREASE the size of each array to something like 20000 each (instead of default 1000), the crashing seems to go away too!!???
From this my first guess would be an out of bounds array access somewhere.

Quote:
Originally Posted by Anomaly View Post
Code:
	double Process(double input) {
		sloop[sindex] = input;
		sindex >= length ? sindex = 0 : sindex++;
		return sloop[sindex];
	};
Bingo, sloop[sindex] will be out of bounds when sindex == length. I would change this to something like this to prevent this:

Code:
	double Process(double input) {
		sloop[sindex] = input;
		if (++sindex >= length) sindex = 0;
		return sloop[sindex];
	};
Tale is offline   Reply With Quote
Old 07-19-2017, 12:58 AM   #4
Anomaly
Human being with feelings
 
Anomaly's Avatar
 
Join Date: Sep 2007
Posts: 642
Default

Thanks Youlean & Tale!

Yeah, my delay was crap I can see it now! Now fixed according to Tale's suggestion and the crashing is gone. I must have overlooked this because the the out of boundary crash didn't occur on run time, which would have been more logical I guess.
__________________
___________________________
Sonic Anomaly | free JSFX & VST Plugins
Anomaly is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:05 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.