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

Improve valgrind support #2718

Merged
merged 2 commits into from
Aug 21, 2018
Merged

Conversation

ChrisJefferson
Copy link
Contributor

This patch greatly improves --enable-valgrind. This puts padding before and after every Bag, so we can detect invalid reads or writes off the beginning and end of every Bag

@ChrisJefferson ChrisJefferson added topic: kernel release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Aug 20, 2018
src/gasman.c Outdated
*/

Bag * NewWeakDeadBagMarker = (Bag *)(1000*sizeof(Bag) + 1L);
Bag * OldWeakDeadBagMarker = (Bag *)(1001*sizeof(Bag) + 1L);
Copy link
Member

Choose a reason for hiding this comment

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

Why is this moved around?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to refer to it in an earlier place in the file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But turns out I didn't end up using that. Taken this part of the PR out.

src/gasman.c Outdated
Int bufsize = (Int)EndBags - (Int)AllocBags;
return bufsize < 4096 ? bufsize : 4096;
VALGRIND_MAKE_MEM_DEFINED(bag, sizeof(Bag));
char* ptr = (char*)PTR_BAG(bag);
Copy link
Member

Choose a reason for hiding this comment

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

clang-format the new code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All formatted

src/gasman.c Outdated
@@ -2043,7 +2094,7 @@ UInt CollectBags (
/* free the identifier */
*(Bag*)(header->link) = FreeMptrBags;
FreeMptrBags = header->link;

Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

Choose a reason for hiding this comment

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

Still is in the diff? But anyway, not important

src/gasman.c Outdated
@@ -202,11 +202,23 @@ enum {
};


static inline UInt WORDS_BAG(UInt size)
// BAG_SLACK is used to define a block of empty space at the end of each
// bag, which can then be marked as "not accessable" in the memory checker
Copy link
Member

Choose a reason for hiding this comment

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

Typo: accessable -> accessible?

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

LGTM

src/gasman.c Outdated
@@ -2043,7 +2094,7 @@ UInt CollectBags (
/* free the identifier */
*(Bag*)(header->link) = FreeMptrBags;
FreeMptrBags = header->link;

Copy link
Member

Choose a reason for hiding this comment

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

Still is in the diff? But anyway, not important

@codecov
Copy link

codecov bot commented Aug 21, 2018

Codecov Report

Merging #2718 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #2718      +/-   ##
==========================================
+ Coverage   75.75%   75.75%   +<.01%     
==========================================
  Files         478      478              
  Lines      241495   241576      +81     
==========================================
+ Hits       182938   183005      +67     
- Misses      58557    58571      +14
Impacted Files Coverage Δ
src/gasman.h 94.87% <ø> (ø) ⬆️
src/gasman.c 87.62% <100%> (+0.06%) ⬆️
src/iostream.c 62.35% <0%> (-1.15%) ⬇️
src/stats.c 90.01% <0%> (+0.39%) ⬆️
hpcgap/lib/hpc/stdtasks.g 64.96% <0%> (+0.51%) ⬆️
src/saveload.c 70.44% <0%> (+2.16%) ⬆️

@fingolfin
Copy link
Member

There is now a merge commit by @markuspf in here. Perhaps @ChrisJefferson can rebase the PR once again to get rid of that?

@markuspf markuspf merged commit 8de7296 into gap-system:master Aug 21, 2018
@ChrisJefferson ChrisJefferson deleted the valgrind branch August 24, 2018 15:51
@fingolfin fingolfin added release notes: added PRs introducing changes that have since been mentioned in the release notes and removed release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Sep 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: added PRs introducing changes that have since been mentioned in the release notes topic: kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants