edwardUL99 / StudSysCppCLI

A CLI UI for the StudSysCpp Project. This is a "dummy" project that is not used but done to practise C++ and also software engineering in terms of issues, issue tracking, issue refinement, requirements engineering, releases and also databases
GNU General Public License v3.0
0 stars 0 forks source link

Verify that destruction of shared entities works correctly #73

Closed edwardUL99 closed 4 years ago

edwardUL99 commented 4 years ago

In PageManager, the destructor caused segmentation faults since it would come across an object already deleted and delete it again. I have this fixed but I haven't tested the behaviour of popCurrentPage since that may also delete some entities. This may cause segmentation faults if not working correctly.

Therefore testing is required to verify that it works correctly as this is a new change added and it could potentially be a breaking change.

You could do this by going to pages which definitely store some objects in the shared entity "pool" and then go back a few pages. Example scenario: -Start the system -Login as a lecturer -Choose to view a module -Go into Announcements of that module -Get back to the WelcomePage by either pressing (B)ack, (C)ancel or (L)ogout

Doing this will definitely invoke popCurrentPage and this will test the destruction of these shared entities. After this occurs ensure the destructor runs correctly as well, as a bug with the popCurrentPage may not show up until the destructor is called

edwardUL99 commented 4 years ago

Valgrind output for terminating the program using Q and not making any calls to popCurrentPage()

eddy@eddy-Ubuntu:~/Coding/C++/StudSysCppCLI$ valgrind --leak-check=yes ./studsys ubuntu.login ==12464== Memcheck, a memory error detector ==12464== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==12464== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info ==12464== Command: ./studsys ubuntu.login ==12464== Welcome to the Student Management System. If you do not have an account, please contact the administration office. Otherwise, login following the commands below

Login as: (L)ecturer or (S)tudent; (C)ancel; (Q)uit l Lecturer Login Page: (E)nter e-mail address, Enter (P)assword, (S)ubmit, (F)orgot password, (C)ancel, (Q)uit e Please enter your e-mail address in the format (first.lastName@staff.mail.ie): test.user@staff.mail.ie Lecturer Login Page: (E)nter e-mail address, Enter (P)assword, (S)ubmit, (F)orgot password, (C)ancel, (Q)uit p Please enter your password: Lecturer Login Page: (E)nter e-mail address, Enter (P)assword, (S)ubmit, (F)orgot password, (C)ancel, (Q)uit s You have been logged in successfully Last login for test.user@staff.mail.ie: 2020-08-17 23:13:31. If the time is suspicious contact the ITT Support Centre immediately.

            Welcome
    Test User
    test.user@staff.mail.ie

(V)iew module sites, (S)ettings, (L)ogout, (Q)uit v List of modules you are registered as the lecturer for: m 1) CS1234 - Test Module Please Choose a (M)odule to view, (C)ancel, (Q)uit: Please choose a number between 1 and 1: 1 Welcome to the homepage for Module CS1234

View: (A)nnouncements, (T)asks, (E)xams, (S)tudent list, (L)ecturer details; Change (M)odule settings, (B)ack, (Q)uit q Goodbye, quitting... ==12464== ==12464== HEAP SUMMARY: ==12464== in use at exit: 0 bytes in 0 blocks ==12464== total heap usage: 5,856 allocs, 5,856 frees, 656,918 bytes allocated ==12464== ==12464== All heap blocks were freed -- no leaks are possible ==12464== ==12464== For lists of detected and suppressed errors, rerun with: -s ==12464== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Quitting frees shared entities successfully, therefore the destructor of PageManager works correctly

Valgrind output for going back to different pages (calling popCurrentPage() which handles deleting entities)

eddy@eddy-Ubuntu:~/Coding/C++/StudSysCppCLI$ valgrind --leak-check=yes ./studsys ubuntu.login ==12549== Memcheck, a memory error detector ==12549== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==12549== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info ==12549== Command: ./studsys ubuntu.login ==12549== Welcome to the Student Management System. If you do not have an account, please contact the administration office. Otherwise, login following the commands below

Login as: (L)ecturer or (S)tudent; (C)ancel; (Q)uit l Lecturer Login Page: (E)nter e-mail address, Enter (P)assword, (S)ubmit, (F)orgot password, (C)ancel, (Q)uit e Please enter your e-mail address in the format (first.lastName@staff.mail.ie): test.user@staff.mail.ie Lecturer Login Page: (E)nter e-mail address, Enter (P)assword, (S)ubmit, (F)orgot password, (C)ancel, (Q)uit p Please enter your password: Lecturer Login Page: (E)nter e-mail address, Enter (P)assword, (S)ubmit, (F)orgot password, (C)ancel, (Q)uit s You have been logged in successfully Last login for test.user@staff.mail.ie: 2020-08-18 21:21:30. If the time is suspicious contact the ITT Support Centre immediately.

            Welcome
    Test User
    test.user@staff.mail.ie

(V)iew module sites, (S)ettings, (L)ogout, (Q)uit v List of modules you are registered as the lecturer for: 1) CS1234 - Test Module Please Choose a (M)odule to view, (C)ancel, (Q)uit: m Please choose a number between 1 and 1: 1 Welcome to the homepage for Module CS4115

View: (A)nnouncements, (T)asks, (E)xams, (S)tudent list, (L)ecturer details; Change (M)odule settings, (B)ack, (Q)uit m Not implemented yet View: (A)nnouncements, (T)asks, (E)xams, (S)tudent list, (L)ecturer details; Change (M)odule settings, (B)ack, (Q)uit a (N)ew announcement, (E)dit announcement, (V)iew announcements, (B)ack, (Q)uit b Welcome to the homepage for Module CS1234

View: (A)nnouncements, (T)asks, (E)xams, (S)tudent list, (L)ecturer details; Change (M)odule settings, (B)ack, (Q)uit b Going back to module selector page

List of modules you are registered as the lecturer for: 1) CS1234 - Test Module Please Choose a (M)odule to view, (C)ancel, (Q)uit: c Welcome Test User test.user@staff.mail.ie

(V)iew module sites, (S)ettings, (L)ogout, (Q)uit l Logging out... Welcome to the Student Management System. If you do not have an account, please contact the administration office. Otherwise, login following the commands below

Login as: (L)ecturer or (S)tudent; (C)ancel; (Q)uit q Goodbye, quitting... ==12549== ==12549== HEAP SUMMARY: ==12549== in use at exit: 0 bytes in 0 blocks ==12549== total heap usage: 5,946 allocs, 5,946 frees, 711,382 bytes allocated ==12549== ==12549== All heap blocks were freed -- no leaks are possible ==12549== ==12549== For lists of detected and suppressed errors, rerun with: -s ==12549== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

I also debugged the code where I stepped into the method responsible for freeing entities to verify that it is determining what entities to be deleted successfully and it appears so.

I am closing this issue, but if any bugs are found down the line, a new issue can be raised