Skip to content

Commit ed966eb

Browse files
committed
add test for segfaults in revwalk
1 parent 5e70611 commit ed966eb

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

generate/partials/sync_function.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
{%partial doc .%}
33
NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
4-
NanScope();
4+
//NanScope();
55
{%partial guardArguments .%}
66

77
{%each .|returnsInfo 'true' as _return %}
@@ -36,7 +36,7 @@ from_{{ arg.name }}
3636
{%if not arg.lastArg %},{%endif%}
3737
{%endeach%}
3838
);
39-
39+
/*
4040
{%each args|argsInfo as arg %}
4141
{%if arg.isCppClassStringOrArray %}
4242
{%if arg.freeFunctionName %}
@@ -46,7 +46,7 @@ from_{{ arg.name }}
4646
{%endif%}
4747
{%endif%}
4848
{%endeach%}
49-
49+
*/
5050
{%if return.isErrorCode %}
5151
if (result != GIT_OK) {
5252
{%each args|argsInfo as arg %}

test/tests/revwalk.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,32 @@ describe("Revwalk", function() {
5757
});
5858
});
5959
});
60+
61+
// This test requires forcing garbage collection, so mocha needs to be run via
62+
// node rather than npm, with a la `node --expose-gc [pathtohmoca] [testglob]`
63+
var testGC = (global.gc ? it : it.skip);
64+
65+
testGC("doesnt segfault when accessing commit.author() twice", function(done) {
66+
this.timeout(10000);
67+
return Repository.open(reposPath).then(function(repository) {
68+
var walker = repository.createRevWalk();
69+
repository.getMaster().then(function(master) {
70+
var did = false;
71+
walker.walk(master, function(error, commit) {
72+
for (var i = 0; i < 1000; i++) {
73+
if (true) {
74+
commit.author().name();
75+
commit.author().email();
76+
}
77+
global.gc();
78+
}
79+
if (!did) {
80+
done();
81+
did = true;
82+
}
83+
});
84+
});
85+
});
86+
});
87+
6088
});

0 commit comments

Comments
 (0)