Menu

#4 SIGSEGV in is_constraint_parameter with small example

1.0.0beta5
closed-could-not-reproduce
nobody
None
1.0alpha2
5
2014-07-24
2007-01-08
No

Hi,

I get a segmentation violation when i use mock-functions with cgreen_1.0alpha2. The attached code reproduces the bug under linux as well as cygwin. Executing the example yields the following stack trace (gdb-output):

Running "main"...

Program received signal SIGSEGV, Segmentation fault.
0x08049916 in is_constraint_parameter (constraint=0x1,
parameter=0x9952438 "i1") at constraint.c:20
20 return strcmp(constraint->parameter, parameter) == 0;
(gdb) bt
#0 0x08049916 in is_constraint_parameter (constraint=0x1,
parameter=0x9952438 "i1") at constraint.c:20
#1 0x080498a8 in apply_any_constraints (expectation=0x99520b0,
parameter=0x9952438 "i1", actual=1) at mocks.c:237
#2 0x080492e1 in _mock (function=0x804a72c "mock_function",
parameters=0x804a73a "i1, i2") at mocks.c:55
#3 0x080487f7 in mock_function ()
#4 0x0804880e in foo ()
#5 0x0804883b in testFoo ()
#6 0x08048f73 in run_the_test_code (suite=0x9952008, test=0x9952020,
reporter=0x9952030) at unit.c:207
#7 0x08048e32 in run_test_in_the_current_process (suite=0x9952008,
test=0x9952020, reporter=0x9952030) at unit.c:160
#8 0x08048cb0 in run_named_test (suite=0x9952008, name=0x804a75e "testFoo",
reporter=0x9952030) at unit.c:132
#9 0x08048adf in run_single_test (suite=0x9952008, name=0x804a75e "testFoo",
reporter=0x9952030) at unit.c:99
#10 0x080488a0 in main ()

Discussion

  • Christian Matuszewski

    Example which reproduces the bug

     
  • Christian Matuszewski

    Logged In: YES
    user_id=1668471
    Originator: YES

    Ok, I overlooked the new "want"-function after you changed the interface. So, when I change the line
    expect(mock_function, 1, 2);
    to
    expect(mock_function, want(i1, 1), want(i2, 2));
    in the attached example all works fine and no segmentation fault occurs.
    But nevertheless I would prefer a meaningful error message to a seg fault, so I keep the bug open.

     
  • Marcus Baker

    Marcus Baker - 2008-03-21

    Logged In: YES
    user_id=695819
    Originator: NO

    Hi.

    Sorry about the interface change :(. I couldn't think of any easy way to keep backward compatibility, and the new interface was compelling.

    I haven't forgotten about this problem, but I've rewritten some of the internals and haven't had a chance to play with it it. As for a non-want parameter in the mock, I don't really know how to handle this as one of the plans is to allow users to write their own wants. This makes it difficult to simply check that the value is a valid want() pointer.

    I'll think about it. maybe i can get new want()'s to register themselves in some way.

    yours, Marcus

     
  • Thomas Nilefalk

    Thomas Nilefalk - 2014-07-24
    • status: open --> wont-fix
    • Found in version: --> 1.0beta4
    • Milestone: --> 1.0.0beta5
     
  • Thomas Nilefalk

    Thomas Nilefalk - 2014-07-24

    Obsolete

     
  • Thomas Nilefalk

    Thomas Nilefalk - 2014-07-24
    • Found in version: 1.0beta4 --> 1.0alpha2
     
  • Thomas Nilefalk

    Thomas Nilefalk - 2014-07-24
    • status: wont-fix --> closed-could-not-reproduce
     

Log in to post a comment.

MongoDB Logo MongoDB