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

check_expected causes segfault. #29

Open
GoogleCodeExporter opened this issue Dec 8, 2015 · 0 comments
Open

check_expected causes segfault. #29

GoogleCodeExporter opened this issue Dec 8, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Compile test-cmockery with 
gcc -std=c99 -I/opt/include -L/opt/lib -lcmockery test-cmockery.c -o 
test-cmockery
2. Run ./test-cmockery

What is the expected output? What do you see instead?
Expected output:
sizeof(unsigned long long): 8
sizeof(unsigned): 4
sizeof(char*): 8
4365541014
70573718
70573718
4365541014
test_demo: Starting test
test_demo: Test completed successfully.
All 1 tests passed

Actual output:
sizeof(unsigned long long): 8
sizeof(unsigned): 4
sizeof(char*): 8
4438503062
143535766
143535766
4438503062
test_demo: Starting test
Segmentation fault: 11
test_demo: Test failed.
1 out of 1 tests failed!
    test_demo


What version of the product are you using? On what operating system?
Git commit: 1c63f1f479463d9cb5185681cf11799e8efa9092
on Macintosh OS X Mountain Lion 10.8.5

Please provide any additional information below.
By modifying the macro cast_to_largest_integral_type (cmockery.h, line 51), it 
is possible to to remove the error and see the expected output. Specifically, 
changing
#define cast_to_largest_integral_type(value)    \
    ((LargestIntegralType)((unsigned)(value))) 
to 
#define cast_to_largest_integral_type(value)                    \
    ((LargestIntegralType)((unsigned long long)(value)))
removes the error. What is the purpose of casting a pointer (8 bytes on my 
system), to an unsigned integer (4 bytes on my system), then back to an 
unsigned long long (8 bytes on my system)?

Original issue reported on code.google.com by btjone...@gmail.com on 4 Jun 2014 at 8:25

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant