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

fix uninitialized memory in TParameter::copy and added unit-test #1892

Merged
merged 2 commits into from
Feb 25, 2014

Conversation

lambday
Copy link
Member

@lambday lambday commented Feb 25, 2014

  • added a automagic unit test for DynamicObjectArray (non empty) for all CSGObjects

@lambday
Copy link
Member Author

lambday commented Feb 25, 2014

@karlnapf @sonney2k @vigsterkr please have a look!

@lambday
Copy link
Member Author

lambday commented Feb 25, 2014

valgrind reveals that we have leak while using DynamicObjectArray of KernelPCA and VwRegressor, rest works fine!

/* check whether ptype is SGOBJECT, if yes we need to initialize
the memory with NULL for the way copy_ptype handles it */
if (m_datatype.m_ptype==PT_SGOBJECT)
memset(*(void**)target->m_parameter, 0, num_bytes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! :)
So, is there a unit test to make this waterproof? Since all tests were green before... ?

@karlnapf
Copy link
Member

@lambday ah nice, I see, great work with this array unit test.

One thing I would like to see though is some more low level tests, have a look into the parameter tests, there is an explicit test for every case in copy_ptype. This should be extended to SG_VECTOR/SG_MATRIX where the primitive is sgobject.

But I will merge this for now, could you add these tiny tests also?

Thanks a ton on this!

karlnapf added a commit that referenced this pull request Feb 25, 2014
fix uninitialized memory in TParameter::copy and added unit-test
@karlnapf karlnapf merged commit e171a2b into shogun-toolbox:develop Feb 25, 2014
@karlnapf
Copy link
Member

@votjakovr does this fix the issues you had?
@lambday what is the issue fixed by this?

@lambday
Copy link
Member Author

lambday commented Feb 25, 2014

@karlnapf this fixes issue #1821
Thanks for merging! I initially wanted to add TParameter tests only, but had some troubles. I will surely add more tests soon!

@votjakovr
Copy link
Contributor

@karlnapf i'll check a little bit later.
Anyway, thanks @lambday for the fix :)

@lambday
Copy link
Member Author

lambday commented Feb 25, 2014

@votjakovr my pleasure! The example you had works fine locally :)

@votjakovr votjakovr mentioned this pull request Feb 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants