[Cs-dev] Some wierd memory management bug...
Date | 2013-05-10 19:28 |
From | Henrik Andersson |
Subject | [Cs-dev] Some wierd memory management bug... |
Attachments | None None |
With the following simple code snippet, the channels are enumerated my csd have 8 channels and i have stepped the code in csoundListChannels(), when the list is build i can inspect all the items and everything is ok, but when the csoundListChannels() the memory corrupts and in my case i get the following result:
Channel 'Accent' Channel '(null)' Csound tidy up: Segmentation fault display cl 1: cl = (controlChannelInfo_t *) 0x7d0d20
(gdb) display cl[0] 2: cl[0] = {name = 0x6f5260 "Accent", type = 49, hints = {behav = CSOUND_CONTROL_CHANNEL_LIN, dflt = 0, min = 0, max = 1.75, x = 0, y = 0, width = 0, height = 1072693248, attributes = 0x0}}
(gdb) display cl[1] 3: cl[1] = {name = 0x0, type = 0, hints = {behav = 7258960, dflt = 0, min = 6.86636248e-44, max = 0, x = 2, y = 0, width = 0, height = 1075052544, attributes = 0x3ff0000000000000 <Address 0x3ff0000000000000 out of bounds>}}
(gdb) display cl[2] 4: cl[2] = {name = 0x407f400000000000 <Address 0x407f400000000000 out of bounds>, type = 0, hints = { behav = CSOUND_CONTROL_CHANNEL_NO_HINTS, dflt = 0, min = 0, max = 0, x = 7296528, y = 0, width = 49,
height = 0, attributes = 0x2 <Address 0x2 out of bounds>}} (gdb) display cl[3] 5: cl[3] = {name = 0x3fe0000000000000 <Address 0x3fe0000000000000 out of bounds>, type = 0, hints = {
behav = CSOUND_CONTROL_CHANNEL_NO_HINTS, dflt = 1.875, min = 0, max = 0, x = 0, y = 0, width = 0, height = 0, attributes = 0x6f3ac0 "Waveform"}} (gdb) display cl[0] 6: cl[0] = {name = 0x6f5260 "Accent", type = 49, hints = {behav = CSOUND_CONTROL_CHANNEL_LIN, dflt = 0, min = 0,
max = 1.75, x = 0, y = 0, width = 0, height = 1072693248, attributes = 0x0}} (gdb) display cl[1] 7: cl[1] = {name = 0x0, type = 0, hints = {behav = 7258960, dflt = 0, min = 6.86636248e-44, max = 0, x = 2, y = 0,
width = 0, height = 1075052544, attributes = 0x3ff0000000000000 <Address 0x3ff0000000000000 out of bounds>}} (gdb) display cl[2] 8: cl[2] = {name = 0x407f400000000000 <Address 0x407f400000000000 out of bounds>, type = 0, hints = {
behav = CSOUND_CONTROL_CHANNEL_NO_HINTS, dflt = 0, min = 0, max = 0, x = 7296528, y = 0, width = 49, height = 0, attributes = 0x2 <Address 0x2 out of bounds>}} (gdb) display cl[3]
9: cl[3] = {name = 0x3fe0000000000000 <Address 0x3fe0000000000000 out of bounds>, type = 0, hints = { behav = CSOUND_CONTROL_CHANNEL_NO_HINTS, dflt = 1.875, min = 0, max = 0, x = 0, y = 0, width = 0, height = 0,
attributes = 0x6f3ac0 "Waveform"}} Note "Waveform" string as attribute pointer, this is a channel name :) /Henrik ------------------------------------------------------------ #include <stdio.h> #include <csound/csound.h> int main(int argc, char **argv)
{ int res, i; CSOUND *cs; controlChannelInfo_t *cl; cs = csoundCreate(NULL); csoundCompile(cs, argc, argv); res = csoundListChannels(cs, &cl);
for (i = 0; i < res; i++) { fprintf(stderr, "Channel '%s'\n", cl[i].name); } csoundDeleteChannelList(cs, cl); } |
Date | 2013-05-11 07:18 |
From | Henrik Andersson |
Subject | Re: [Cs-dev] Some wierd memory management bug... |
Attachments | None None |
Oh, this might be related to Stevens rewrite of hash table, down the code chain i see mmalloc()'s 2013/5/10 Henrik Andersson <henrik.4e@gmail.com>
|
Date | 2013-05-11 10:30 |
From | Henrik Andersson |
Subject | Re: [Cs-dev] Some wierd memory management bug... |
Attachments | None None |
This is still a problem even with Stevens latest changes... I cant find the source to the problem, when csoundListChannels() returns the data is corrupted in variable cl in the test program provided. First entry is fine, but the rest is garbage..
/H 2013/5/11 Henrik Andersson <henrik.4e@gmail.com>
|
Date | 2013-05-11 10:43 |
From | Steven Yi |
Subject | Re: [Cs-dev] Some wierd memory management bug... |
Hi Henrik, I'll add your code snippet as a unit test and will try to debug now. Thanks! steven On Sat, May 11, 2013 at 11:30 AM, Henrik Andersson |
Date | 2013-05-11 10:44 |
From | Steven Yi |
Subject | Re: [Cs-dev] Some wierd memory management bug... |
Hi Henrik, Could you post the CSD you used with the example code? THanks! steven On Sat, May 11, 2013 at 11:43 AM, Steven Yi |
Date | 2013-05-11 11:11 |
From | Steven Yi |
Subject | Re: [Cs-dev] Some wierd memory management bug... |
I'm unable to reproduce the bug with various chn_k and chn_a calls in the test. I'll load up Ubuntu now to build there to see if it's a platform specific issue. On Sat, May 11, 2013 at 11:44 AM, Steven Yi |
Date | 2013-05-11 11:18 |
From | Henrik Andersson |
Subject | Re: [Cs-dev] Some wierd memory management bug... |
Attachments | None None |
I'm on x86_64 fedora. You will find my failing csound instrument here: http://pastebin.com/kZmpptpu
/H 2013/5/11 Steven Yi <stevenyi@gmail.com> I'm unable to reproduce the bug with various chn_k and chn_a calls in |
Date | 2013-05-11 11:46 |
From | Steven Yi |
Subject | Re: [Cs-dev] Some wierd memory management bug... |
I tried a reduced test on OSX and found no issues. On Ubuntu 32-bit the standard unit tests had some crashes when I run it with ctest, but not when I run the test on commandline which is strange. I have a VM with Fedora x86_64 that I'll try in a bit as my Ubuntu machine got into an odd state (sort of halfway updated to 13.04... X_X). On Sat, May 11, 2013 at 12:18 PM, Henrik Andersson |
Date | 2013-05-11 12:24 |
From | Henrik Andersson |
Subject | Re: [Cs-dev] Some wierd memory management bug... |
Attachments | None None |
I found the problem, let me get back with a patch. 2013/5/11 Steven Yi <stevenyi@gmail.com> I tried a reduced test on OSX and found no issues. On Ubuntu 32-bit |
Date | 2013-05-11 12:47 |
From | Henrik Andersson |
Subject | Re: [Cs-dev] Some wierd memory management bug... |
Attachments | None None |
This is the problem, controlChannelInfo_t contains MYFLT, which in my csound lib is 8 bytes and when my host is compiled it is 4, however if i pass -DUSE_DOUBLE it is solved.. 2013/5/11 Henrik Andersson <henrik.4e@gmail.com>
|
Date | 2013-05-11 13:05 |
From | Steven Yi |
Subject | Re: [Cs-dev] Some wierd memory management bug... |
That's good to hear it's just a configuration issue. We might want to consider just flipping double as default and change the USE_DOUBLE macro to USE_FLOAT. On Sat, May 11, 2013 at 1:47 PM, Henrik Andersson |
Date | 2013-05-11 13:07 |
From | Henrik Andersson |
Subject | Re: [Cs-dev] Some wierd memory management bug... |
Attachments | None None |
Better off, generate a csound.h file that matches the build of the library ? 2013/5/11 Steven Yi <stevenyi@gmail.com> That's good to hear it's just a configuration issue. We might want to |
Date | 2013-05-11 13:08 |
From | Henrik Andersson |
Subject | Re: [Cs-dev] Some wierd memory management bug... |
Attachments | None None |
something in line with: generate csound_config.h with the build settings such as USE_DOUBLE etc, include it in csound.h at top.
2013/5/11 Henrik Andersson <henrik.4e@gmail.com>
|
Date | 2013-05-11 13:14 |
From | Steven Yi |
Subject | Re: [Cs-dev] Some wierd memory management bug... |
CMake has a feature [1] for configuration that is similar to autoconf's config.h.in. Victor added something similar a while back (float-version.h, float-version-double.h), but I don't quit recall when that header is used. We should probably look at using the CMake platform checks and modify the CMakeFiles to not add all of the options as commandline -D flags and instead use a config.h.in file. Something to add to the TODO list. [1] - http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks On Sat, May 11, 2013 at 2:08 PM, Henrik Andersson |