SIGSEV in gtest on Cygwin

153 views
Skip to first unread message

Giaco777

unread,
Jan 31, 2012, 5:03:40 AM1/31/12
to Google C++ Mocking Framework
Hi,

I run the following environment:

- Windows XP
- Eclipse Version: Indigo Service Release 1 Build id: 20110916-0149
- cygwin latest (downloaded 30.01.2012)
- gmock-1.6.0.zip

I first tried some toy application using the turtle example from the
forDummies document (see below).

Building works fine, but if I run the example I get an SIGSEV error in
the shell and when using Eclipse the following messages are shown in
the console:

13 [main] google_mock 3932 exception::handle: Exception:
STATUS_ACCESS_VIOLATION
1122 [main] google_mock 3932 open_stackdumpfile: Dumping stack
trace to google_mock.exe.stackdump

In gdb (no Eclipse), the following line is indicated as the source
line of the error:

Program received signal SIGSEGV, Segmentation fault.
0x00432af2 in join (ptr=0x611d7cd4, this=0x6fa6a4)
at ./gtest/include/gtest/internal/gtest-linked_ptr.h:113
113 while (p->next_ != ptr)


Could you have a look into this?

Giaco777

-------------------------------------------------------------------------
Code:
/*
* main.cc
*
* Created on: Jan 30, 2012
* Author: jknaeb00
*/

#include "gmock/gmock.h"
#include "gtest/gtest.h"



class Turtle {
public:
virtual ~Turtle() {}
virtual void PenUp() = 0;
virtual void PenDown() = 0;
virtual void Forward(int distance) = 0;
virtual void Turn(int degrees) = 0;
virtual void GoTo(int x, int y) = 0;
virtual int GetX() const = 0;
virtual int GetY() const = 0;
};


class MockTurtle : public Turtle {
public:
MOCK_METHOD0(PenUp, void());
MOCK_METHOD0(PenDown, void());
MOCK_METHOD1(Forward, void(int distance));
MOCK_METHOD1(Turn, void(int degrees));
MOCK_METHOD2(GoTo, void(int x, int y));
MOCK_CONST_METHOD0(GetX, int());
MOCK_CONST_METHOD0(GetY, int());
};

using ::testing::AtLeast; // #1

TEST(PainterTest, CanDrawSomething) {
MockTurtle turtle; // #2
EXPECT_CALL(turtle, PenDown()) // #3
.Times(AtLeast(1));
} // #5

int main(int argc, char *argv[]) {
// The following line must be executed to initialize Google Mock
// (and Google Test) before running the tests.
::testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
}

Keith Ray

unread,
Feb 13, 2012, 5:17:13 PM2/13/12
to Google C++ Mocking Framework
Can you reply with the contents of google_mock.exe.stackdump ?

Are you building gmock and gtest with the same options as your test?

They should all link to the same C++ run-time libraries.
gtest and gmock should be static libraries.

--
C. Keith Ray
twitter: @ckeithray
http://agilesolutionspace.blogspot.com/

Reply all
Reply to author
Forward
0 new messages