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

Bug hunting #19

Merged
merged 28 commits into from
Jan 20, 2019
Merged

Bug hunting #19

merged 28 commits into from
Jan 20, 2019

Conversation

ovhpa
Copy link
Collaborator

@ovhpa ovhpa commented Jan 19, 2019

Dear Prof. Rohl,

I have recently been using clang static analysis tool to remove some bugs.
Even though most of these bugs didn't affect the normal operation of GDIS, I feel there have been some improvement in stability and speed after that (but that might actually be only my imagination).

Sincerely,

… 735085; file_cssr.c: FIX restrict-qualified parameter violations; file_xtl.c: FIX restrict-qualified parameter violation
…506; gui_gulp.c: 3b7f02; gui_help.c: 53421d; gui_measure.c: c315f7; gui_shorts.c: 5c2f9f
…rind; project.c: FIX a02228 11b326; select.c: FIX 2553f8; sgclib.c: FIX 38f5f9; space.c: FIX 54e255
…tdated debug; surface.c: remove unused variable
@ovhpa
Copy link
Collaborator Author

ovhpa commented Jan 19, 2019

Here are the statistics of the correction I made on clang bugs (total 152 bugs):

  • Dead store
    • Dead assignment 84
    • Dead increment 2

Most of these bugs are unimportant such as:

//some code
i=0;/*i is set but lost as the next instruction re-set it*/
for(i=0;i<N;i++){
//some code

or places where some value is set but never read:

void function(){
int i;
//some code
i=0;/*i is set but lost as the function return*/
return;
}

Even though there is no gain in removing them, I did it for the clean-up ;)

  • Logic error
    • Assigned value is garbage or undefined 7
    • Branch condition evaluates to a garbage value 1
    • Dereference of null pointer 11
    • Dereference of undefined pointer value 6
    • Result of operation is garbage or undefined 5
    • Uninitialized argument value 9

Some of these bugs have require quite some change but in most cases they resolve to an unprobable case in which someone is trying to feed corrupt or unrelated data into a function.

  • Memory error
    Memory leak 22
    Use of zero allocated 3
    Use-after-free 2

These where actually mostly some memory cleaning bugs (missing g_free).

@ovhpa
Copy link
Collaborator Author

ovhpa commented Jan 19, 2019

PS: In case some problem appear, there is a number on each bug report that I can use to see exactly what went wrong.

@arohl
Copy link
Owner

arohl commented Jan 20, 2019

Oddly the compile on my Mac crashes if I use clang via the makefile but is OK if I compile in Xcode (which uses clang) or use gcc...

@arohl arohl merged commit ccd917c into arohl:master Jan 20, 2019
@ovhpa
Copy link
Collaborator Author

ovhpa commented Jan 21, 2019

I used clang static analysis tool on a gcc build by running:

scan-build -v make -j

while using a makefile.linux containing only gcc.

It's strange but the build using clang also fails for me (on file gui_edit.c).
I will investigate a little more on that issue...
It seems that gui_edit.c (and GDIS) can be compiled by clang:

clang -Wall -O0 -DWITH_GUI  -c gui_edit.c  `pkg-config --cflags gtk+-2.0 gthread-2.0 gtkglext-1.0 gmodule-2.0`

but will fail if any optimization level is used:

clang -Wall -O1 -DWITH_GUI  -c gui_edit.c  `pkg-config --cflags gtk+-2.0 gthread-2.0 gtkglext-1.0 gmodule-2.0`
clang-6.0: error: unable to execute command: Segmentation fault (core dumped)
clang-6.0: error: clang frontend command failed due to signal (use -v to see invocation)

Can you confirm?

@ovhpa ovhpa deleted the bug_hunting branch January 21, 2019 04:51
@arohl
Copy link
Owner

arohl commented Jan 21, 2019 via email

@ovhpa
Copy link
Collaborator Author

ovhpa commented Jan 21, 2019

Thank you for confirming.

I will try to look after this bug in this week.
If it's not too big, can you send me the corresponding .crash file by PM?

I think it would be nice if we can have clang to generate GDIS, in addition to gcc.

@arohl
Copy link
Owner

arohl commented Jan 21, 2019 via email

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

Successfully merging this pull request may close these issues.

2 participants