Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csound memory issue on OSX #506

Closed
benhackbarth opened this issue Jul 17, 2015 · 14 comments
Closed

csound memory issue on OSX #506

benhackbarth opened this issue Jul 17, 2015 · 14 comments

Comments

@benhackbarth
Copy link

Hi all,

I’m trying to chase down a memory issue with the latest csound (6.05) on OSX built from git. I frequently get malloc errors when running this csd file: http://pastebin.com/Wndeh5Qf

Note that sometimes compilation completes successfully, other times it exits with an error, at other times the process hangs. Here is the shell output of this csd with the malloc error message: http://pastebin.com/n05Ycywj

And here is the output of valgrind using this csd on OSX 10.9.5: http://pastebin.com/fMBjUrXP

I cannot seem to reproduce the malloc fatal error when using valgrind, but it does consistently report some issues, perhaps especially pertinent around line 153.

Sorry that I cannot provide a csd that works independently of my soundfile database — removing/changing path names seems to affect whether or not this error occurs.

Best, Ben

@benhackbarth benhackbarth changed the title malloc csound memory issue on OSX Jul 17, 2015
@jpffitch jpffitch added the OSX label Jul 19, 2015
@jpffitch
Copy link
Contributor

Hard to see what to do as the input is so specific. e valgrind issue suggests it is in a string assignment but the code looks sufficiently defensive. You coud try running under gdb and look at the function copy_string_value, in particular the size od dst ad src

@benhackbarth
Copy link
Author

copy_string_value seemed to be working as expected.

I've discovered the issue: line 117 uses '=' to assign a string variable (
"SspatAlgorithm = p75"). Changing this to strget seems to stop the periodic seg faults. If '=' isn't supported for strings (?), I would suggest throwing an error.

@megastep
Copy link
Contributor

I'm also seeing some apparently related crashes on iOS with the code from the current devel branch. The address sanitizer in Xcode 7 picked up some invalid uses of strcpy() with overlapping addresses (basically copying a string to itself) in some of the code setting the configuration variables. I'm trying to investigate this further...

@benhackbarth
Copy link
Author

Still having issues with this myself. My attempts to make a demonstrative csd which is untangled from local file dependancies has proven difficult. Will keep trying..

@megastep
Copy link
Contributor

This patch helped me with some of the crashes I have been experiencing, some unsafe dealings with memory in the MIDI code, I suspect this might be the case in other areas. You may want to check it out.

https://github.com/audiokit/csound/commit/20f2547dc2ee74cbd175268d268a09521f13aba7

@vlazzarini
Copy link
Member

@megastep can you submit your patch as a pull request ? It will be more easily dealt with

@megastep
Copy link
Contributor

@vlazzarini I suppose, this branch has a lot of other commits I don't really want to bundle with this, but I'll do it from another branch.

@vlazzarini
Copy link
Member

Thanks, that's helpful

@benhackbarth
Copy link
Author

I’ve removed the file dependancies and, with this csd, I am getting the same valgrind errors.

http://pastebin.com/tHMe15Li

It seems to be a strange confluence of factors causing this, dependant on both the Udo and the strings. Perhaps it has to do with string handling in useropcd2? Really a shot in the dark though.

==23949== Invalid write of size 8
==23949== at 0x66AB91: _platform_memmove$VARIANT$Unknown (in /usr/lib/system/libsystem_platform.dylib)
==23949== by 0x324AD: string_copy_value (in /Users/ben/Library/Frameworks/CsoundLib64.framework/Versions/6.0/CsoundLib64)
==23949== by 0x1007933EF: ???
==23949== Address 0x101b619be is 62 bytes inside a block of size 66 alloc'd
==23949== at 0x47E1: malloc (vg_replace_malloc.c:300)
==23949== by 0x23F53: mmalloc (in /Users/ben/Library/Frameworks/CsoundLib64.framework/Versions/6.0/CsoundLib64)
==23949==
==23949== Invalid write of size 8
==23949== at 0x66AB91: _platform_memmove$VARIANT$Unknown (in /usr/lib/system/libsystem_platform.dylib)
==23949== by 0x324AD: string_copy_value (in /Users/ben/Library/Frameworks/CsoundLib64.framework/Versions/6.0/CsoundLib64)
==23949== by 0x10035AC1F: ???
==23949== by 0x2079E7: ??? (in /Users/ben/Library/Frameworks/CsoundLib64.framework/Versions/6.0/CsoundLib64)
==23949== by 0x1007933EF: ???
==23949== by 0x21C65: useropcd2 (in /Users/ben/Library/Frameworks/CsoundLib64.framework/Versions/6.0/CsoundLib64)
==23949== by 0x1000E6C1F: ???
==23949== by 0x1005D114F: ???
==23949== by 0x1007B2A8F: ???
==23949== by 0x1000DF44F: ???
==23949== by 0x10038F78F: ???
==23949== by 0x1013FFDBF: ???
==23949== Address 0x101b619be is 62 bytes inside a block of size 66 alloc'd
==23949== at 0x47E1: malloc (vg_replace_malloc.c:300)
==23949== by 0x23F53: mmalloc (in /Users/ben/Library/Frameworks/CsoundLib64.framework/Versions/6.0/CsoundLib64)
==23949==

@megastep
Copy link
Contributor

megastep commented Aug 6, 2015

This may or may not help with this bug, but I just made a bunch of weird crashes go away simply by reverting this commit: 24b7e94

@benhackbarth
Copy link
Author

Thanks Stéphane. I should have mentioned: I’ve cloned into origin/release/6.05 to avoid any issues in the dev branch. So my errors in valgrind are coming from the 6.05 release version.

Best,
– ben

On 6 Aug 2015, at 09:52, Stéphane Peter notifications@github.com wrote:

This may or may not help with this bug, but I just made a bunch of weird crashes go away simply by reverting this commit: 24b7e94


Reply to this email directly or view it on GitHub.

@vlazzarini
Copy link
Member

Hi Ben, could you check this now with the latest sources to see if the string fixes that were committed yesterday help your problem in any way?

@vlazzarini vlazzarini added the bug label Aug 27, 2015
@benhackbarth
Copy link
Author

Seems like this has taken care of my problems, thanks Victor & John. Will report back if I discover any additional issues.

@vlazzarini
Copy link
Member

OK, I'll close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants