-
Notifications
You must be signed in to change notification settings - Fork 757
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
NRT realloc failure #1537
Comments
What did you realloc? A |
I did not realloc anything. NRT does realloc according to commit f3f0f81 to avoid 8192 limit. It is the first time I try NRT so the issue appears now |
solved the issue but need some supervision: in SC_ World.cpp
so that malloc is not malloc but nova:malloc_aligned solutions: 2--wraping malloc as:
and using malloc_orig worked for me 3-changing defines as:
did not work for me althought it should have |
Good catch Victor. I just checked a spec and yes realloc behaviour is undefined if applied to memory not allocated from the standard functions. The #define is used only in SC_World.cpp and then used a small number of times, so it should be safe to rename it as something local such as "debuggable_malloc(size)", i.e. your option 1. |
As the problem only seems to appear on win32 (macosx uses malloc as malloc_aligned and nobody complains on linux) I can make a commit and PR for that. |
Can anybody explain me why option 3 is not working? |
first I would like to ask tim @timblechmann which are the allocations that must be aligned an which not |
sc_malloc was always aligned and it is passed to plugins via the interface table. in general memory should be aligned. many malloc implementations provide aligned memory by default (most notably apple's malloc), while some don't (win32 malloc). |
Should OSC_Packet.mData be aligned? |
it doesn't harm ... but it probably won't crash if it isn't |
Dan says #define malloc sc_malloc only affects SC_World.cpp but I just found
So if I change this define it will affect other cpp files perhaps? |
it will not affect other cpp files. but it is added as a function pointer to the interface table. this means that it can potentially be called everywhere: supercollider/server/scsynth/SC_World.cpp Line 212 in f3f0f81
obviously this is broken as well. best way is to implement an sc_realloc based on sc_malloc and sc_free. |
I have seen some realloc calls in sc code.
in SC_GraphDef.cpp:827 |
check where the memory is coming from! is it allocated via the function table? |
Thats true it comes from calloc.
|
calloc is equivalent to malloc+memset: http://en.cppreference.com/w/c/memory/calloc cannot comment about your "option 3", but make sure that malloc_orig won't resolve to ::sc_malloc ... e.g. by checking the preprocessed sources |
made PR #1549 |
How could this bug live for so long time without complains. One conclusion could be: nobody uses NRT in win32 (until now) |
Could somebody merge? |
Hello,
I had too comment this lines (SC_World.cpp:553)
packet->mData = (char *)realloc((void *)packet->mData, (size_t)msglen);
if(!packet->mData) throw std::runtime_error("nextOSCPacket: realloc
failed...\n");
to avoid error in realloc in NRT
I cant see why (msglen was not 0)
any ideas?
(win32 vista mingw-w64 32 bits)
victor
The text was updated successfully, but these errors were encountered: