Skip to content

Commit f7faa02

Browse files
authored
Merge pull request #842 from yc2lee/v3-updates-mem-leak
Old Seashell (v3) Updates: * Hack around issue #836 by using clang executable, which finds the memory leak properly * Log out button should go back to Seashell sign-in page instead of CAS * Update sign-in page with supported browsers and better "wrong password" message * Disable offline mode
2 parents d69ce30 + 3120fb1 commit f7faa02

File tree

7 files changed

+81
-7
lines changed

7 files changed

+81
-7
lines changed

src/backend/compiler/compiler.cc

+24
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ struct seashell_compiler {
159159
/** Object files discovered by dependency resolution */
160160
std::vector<std::string> object_paths;
161161

162+
/** All source_paths and object_paths joined into one string */
163+
std::string dep_paths;
164+
162165
/** Module compilation messages. */
163166
std::vector<seashell_diag> messages;
164167

@@ -540,6 +543,27 @@ std::string seashell_compiler_get_object(struct seashell_compiler* compiler) {
540543
#endif
541544
}
542545

546+
#ifndef __EMSCRIPTEN__
547+
extern "C" const char *seashell_compiler_get_dep_paths(struct seashell_compiler *compiler) {
548+
#else
549+
std::string seashell_compiler_get_dep_paths(struct seashell_compiler *compiler) {
550+
#endif
551+
compiler->dep_paths = "";
552+
for(int i=0; i<compiler->source_paths.size(); i++) {
553+
compiler->dep_paths += compiler->source_paths[i];
554+
compiler->dep_paths += " ";
555+
}
556+
for(int i=0; i<compiler->object_paths.size(); i++) {
557+
compiler->dep_paths += compiler->object_paths[i];
558+
compiler->dep_paths += " ";
559+
}
560+
#ifndef __EMSCRIPTEN__
561+
return compiler->dep_paths.c_str();
562+
#else
563+
return compiler->dep_paths;
564+
#endif
565+
}
566+
543567
/**
544568
* seashell_compiler_object_arch (struct seashell_compiler* compiler)
545569
* Returns a string representing the resulting object's architecture, if any.

src/backend/compiler/compiler.h

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ std::string seashell_compiler_get_diagnostic_message(struct seashell_compiler* c
3636
std::string seashell_compiler_object_arch(struct seashell_compiler* compiler);
3737
std::string seashell_compiler_object_os (struct seashell_compiler* compiler);
3838
std::string seashell_compiler_get_object_dep(struct seashell_compiler *compiler, int k);
39+
std::string seashell_compiler_get_dep_paths(struct seashell_compiler *compiler);
3940
#else
4041
extern "C" const char* seashell_clang_version();
4142
extern "C" void seashell_compiler_set_main_file(struct seashell_compiler *compiler, const char *file);
@@ -49,6 +50,7 @@ extern "C" const char * seashell_compiler_get_diagnostic_message (struct seashel
4950
extern "C" const char* seashell_compiler_object_arch (struct seashell_compiler* compiler);
5051
extern "C" const char* seashell_compiler_object_os (struct seashell_compiler* compiler);
5152
extern "C" const char *seashell_compiler_get_object_dep(struct seashell_compiler *compiler, int k);
53+
extern "C" const char *seashell_compiler_get_dep_paths(struct seashell_compiler *compiler);
5254
#endif
5355
extern "C" struct seashell_compiler* seashell_compiler_make (void);
5456
extern "C" void seashell_compiler_free (struct seashell_compiler* compiler);

src/collects/seashell/compiler/compiler.rkt

+35-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
;;
1717
;; You should have received a copy of the GNU General Public License
1818
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
19-
(require seashell/compiler/ffi
19+
(require seashell/compiler/ffi seashell/log
2020
(submod seashell/seashell-config typed))
2121
(require/typed racket/base
2222
[file-position (case-lambda
@@ -162,6 +162,40 @@
162162
;; Remove the object file.
163163
(delete-file object-file)
164164

165+
;;-------------------------------------------------------
166+
;;
167+
;; yc2lee's hack to use clang executable instead of
168+
;; custom Seashell clang/llvm wrapper
169+
;;
170+
171+
(define clang-binary-path (build-path SEASHELL_INSTALL_PATH "bin" "clang-3.9"))
172+
(when (and (equal? 0 linker-res)
173+
(file-exists? clang-binary-path)
174+
(member 'execute (file-or-directory-permissions clang-binary-path)))
175+
(define clang-binary-arguments
176+
`("-std=c99"
177+
"-fsanitize=address" "-fno-omit-frame-pointer" "-fno-common"
178+
"-g" "-O0"
179+
,@(map (lambda ([dir : Path]) (string-append "-I" (path->string dir))) source-dirs)
180+
"-lm"
181+
"-o" ,result-file
182+
,@(string-split (seashell_compiler_get_dep_paths compiler))))
183+
(logf 'info "Running clang compiler: ~a ~a" clang-binary-path clang-binary-arguments)
184+
;; Run the clang executable
185+
(define-values (clang-result clang-stdout clang-stdin clang-stderr)
186+
(apply subprocess #f #f #f clang-binary-path clang-binary-arguments))
187+
(close-output-port clang-stdin)
188+
;; Get stdout and stderr contents
189+
(logf 'info "clang compiler stdout: ~a" (port->string clang-stdout))
190+
(close-input-port clang-stdout)
191+
(logf 'info "clang compiler stderr: ~a" (port->string clang-stderr))
192+
(close-input-port clang-stderr)
193+
(define clang-binary-exit-code (subprocess-status (sync clang-result)))
194+
(logf 'info "clang compiler exited with code ~a" clang-binary-exit-code))
195+
196+
;;
197+
;;---------------------------------------------------
198+
165199
;; Read the result:
166200
(define linker-result
167201
(cond

src/collects/seashell/compiler/ffi.rkt

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
seashell_compiler_get_diagnostic_message
4141
seashell_compiler_run
4242
seashell_compiler_get_object
43+
seashell_compiler_get_dep_paths
4344
seashell_clang_version
4445
seashell_compiler_object_arch
4546
seashell_compiler_object_os
@@ -99,6 +100,8 @@
99100
(memcpy result address size)
100101
result]
101102
[else #f])))))
103+
(define-clang seashell_compiler_get_dep_paths
104+
(_fun _seashell_compiler-ptr -> _string/utf-8))
102105
(define-clang seashell_compiler_get_object_dep_count
103106
(_fun _seashell_compiler-ptr -> _int))
104107
(define-clang seashell_compiler_get_object_dep
@@ -122,6 +125,7 @@
122125
[seashell_compiler_get_diagnostic_column (-> Seashell-Compiler-Ptr Nonnegative-Integer Index)]
123126
[seashell_compiler_get_diagnostic_file (-> Seashell-Compiler-Ptr Nonnegative-Integer String)]
124127
[seashell_compiler_get_diagnostic_message (-> Seashell-Compiler-Ptr Nonnegative-Integer String)]
128+
[seashell_compiler_get_dep_paths (-> Seashell-Compiler-Ptr String)]
125129
[seashell_compiler_run (-> Seashell-Compiler-Ptr Boolean Fixnum)]
126130
[seashell_compiler_object_arch (-> Seashell-Compiler-Ptr String)]
127131
[seashell_compiler_object_os (-> Seashell-Compiler-Ptr String)]
@@ -146,6 +150,7 @@
146150
seashell_compiler_get_diagnostic_message
147151
seashell_compiler_run
148152
seashell_compiler_get_object
153+
seashell_compiler_get_dep_paths
149154
seashell_clang_version
150155
seashell_compiler_object_arch
151156
seashell_compiler_object_os

src/frontend/frontend/frontend.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ angular.module('frontend-app', ['seashell-websocket', 'seashell-projects', 'ngCo
111111
"Do you wish to logout? Any unsaved data will be lost.")
112112
.then(function () {
113113
$cookies.remove(SEASHELL_CREDS_COOKIE);
114-
$window.top.location = "https://cas.uwaterloo.ca/logout";
114+
$window.top.location = "https://www.student.cs.uwaterloo.ca/~cs136/seashell-old/"; // "https://cas.uwaterloo.ca/logout";
115115
});
116116
};
117117
// Settings

src/frontend/frontend/templates/settings-template.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ <h4 class="modal-title">
5959
Disabled
6060
</label>
6161
<label class="radio-inline">
62-
<input name="offline-mode" type="radio" ng-model="temp.offline_mode" ng-value="1">
62+
<input name="offline-mode" type="radio" ng-model="temp.offline_mode" ng-value="1" disabled>
6363
Enabled
6464
</label>
6565
<label class="radio-inline">
66-
<input name="offline-mode" type="radio" ng-model="temp.offline_mode" ng-value="2">
66+
<input name="offline-mode" type="radio" ng-model="temp.offline_mode" ng-value="2" disabled>
6767
Forced
6868
</label>
6969
</div>

src/frontend/index.html

+12-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@
1919
<link href="//fonts.googleapis.com/css?family=Unkempt:700" rel="stylesheet" type="text/css">
2020
<div id="seashell-logo" class="col-md-6 col-xs-6 text-left" style="padding: 0">
2121
<span style="font-family: 'Unkempt', cursive; font-size: 25px; color: #888">seashell</span>
22-
<span style="font-size: 14px; color: black; font-variant: small-caps; color: #888; position: absolute">beta</span>
22+
<span style="font-size: 14px; color: black; font-variant: small-caps; color: #888; position: absolute">3.0.4</span>
2323
</div>
2424
</div>
2525
</header>
2626
<div class="container" ng-controller="LoginController as login">
2727
<form class="form-signin" role="form" ng-submit="login.login()">
28-
<h2 class="form-signing-heading">Please sign in with your student.cs credentials</h2>
28+
<h2 class="form-signing-heading">Please sign in with your <a href="https://www.student.cs.uwaterloo.ca/password/">student.cs</a> credentials</h2>
29+
<div>Supported browsers:
30+
<ul>
31+
<li><a href="https://www.mozilla.org/firefox/">Firefox 54 - 57</a></li>
32+
<li><a href="https://www.google.com/chrome/">Google Chrome 60 - 62</a></li>
33+
</ul>
34+
</div>
2935

3036
<input type="text" class="form-control" placeholder="Username" ng-model="login.user" id="user"
3137
ng-disabled="login.busy" />
@@ -38,7 +44,10 @@ <h2 class="form-signing-heading">Please sign in with your student.cs credentials
3844
Logging in...
3945
</div>
4046
<div class="alert alert-danger" ng-show="login.error" ng-cloak>
41-
{{login.error}}
47+
Error message: <b>{{(login.error.responseJSON.error.message === "Invalid credentials." ||
48+
login.error.responseJSON.error.message === "Bad password provided.")
49+
? "Invalid Username and/or Password" : login.error.responseJSON.error.message}}</b><br>
50+
Extra info: {{login.error.status}} {{login.error.statusText}}
4251
</div>
4352
</form>
4453
</div>

0 commit comments

Comments
 (0)