Merge pull request #1029 from urbit/release-candidate-plug-leaks

fix memory leaks, add gc and profile build options
This commit is contained in:
Joe Bryan 2018-10-02 18:09:11 -04:00 committed by GitHub
commit 89d4db1dce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 29 deletions

View File

@ -10,4 +10,7 @@
#mesondefine U3_OS_ENDIAN_little
#mesondefine U3_OS_ENDIAN_big
#mesondefine U3_MEMORY_DEBUG
#mesondefine U3_CPU_DEBUG
#endif /*CONFIG_H*/

View File

@ -2,12 +2,6 @@
**
** This file is in the public domain.
*/
/** Options.
**/
/* U3_MEMORY_DEBUG: add debugging information to heap. Breaks image.
*/
# undef U3_MEMORY_DEBUG
/** Constants.
**/
/* u3a_bits: number of bits in word-addressed pointer. 29 == 2GB.

View File

@ -2,12 +2,6 @@
**
** This file is in the public domain.
*/
/** Options.
**/
/* U3_CPU_DEBUG: activate profiling.
*/
# undef U3_CPU_DEBUG
/** Data structures.
**/
/* u3t_trace: fast execution flags.

View File

@ -264,6 +264,8 @@ incdir = include_directories('include/')
conf_data = configuration_data()
conf_data.set('URBIT_VERSION', '"0.6.0"')
conf_data.set('U3_MEMORY_DEBUG', get_option('gc'))
conf_data.set('U3_CPU_DEBUG', get_option('prof'))
osdet = build_machine.system()
os_c_flags = ['-funsigned-char','-ffast-math']

4
meson_options.txt Normal file
View File

@ -0,0 +1,4 @@
option('gc', type : 'boolean', value : false,
description : 'Add debugging information to heap. Run with -g. Breaks image.')
option('prof', type : 'boolean', value : false,
description : 'Activate profiling. Run with -P.')

View File

@ -1383,7 +1383,8 @@ _http_serv_start_all(void)
c3_assert( 0 != for_u );
u3_lo_open();
// disabled, as this causes a memory leak
// u3_lo_open();
// if the SSL_CTX existed, it'll be freed with the servers
u3_Host.tls_u = 0;
@ -1444,7 +1445,8 @@ _http_serv_start_all(void)
_http_write_ports_file(u3_Host.dir_c);
_http_form_free();
u3_lo_shut(c3y);
// disabled, see above
// u3_lo_shut(c3y);
}
/* _http_serv_restart(): gracefully shutdown, then start servers.
@ -1499,15 +1501,26 @@ _http_form_free(void)
void
u3_http_ef_form(u3_noun fig)
{
// XX validate / test axes?
u3_noun sec = u3h(fig);
u3_noun lob = u3t(fig);
u3_noun sec, pro, log, red;
if ( (c3n == u3r_qual(fig, &sec, &pro, &log, &red) ) ||
// confirm sec is a valid (unit ^)
!( u3_nul == sec || ( c3y == u3du(sec) &&
c3y == u3du(u3t(sec)) &&
u3_nul == u3h(sec) ) ) ||
// confirm valid flags ("loobeans")
!( c3y == pro || c3n == pro ) ||
!( c3y == log || c3n == log ) ||
!( c3y == red || c3n == red ) ) {
uL(fprintf(uH, "http: form: invalid card\n"));
u3z(fig);
return;
}
u3_form* for_u = c3_malloc(sizeof(*for_u));
for_u->pro = (c3_o)u3h(lob);
for_u->log = (c3_o)u3h(u3t(lob));
for_u->red = (c3_o)u3t(u3t(lob));
for_u->pro = (c3_o)pro;
for_u->log = (c3_o)log;
for_u->red = (c3_o)red;
if ( u3_nul != sec ) {
u3_noun key = u3h(u3t(sec));
@ -2811,15 +2824,13 @@ _proxy_serv_start(u3_prox* lis_u)
void
u3_http_ef_that(u3_noun tat)
{
u3_noun sip = u3h(tat);
u3_noun por = u3h(u3t(tat));
u3_noun sec = u3h(u3t(u3t(tat)));
u3_noun non = u3t(u3t(u3t(tat)));
u3_noun sip, por, sec, non;
if( c3n == u3ud(sip) ||
c3n == u3a_is_cat(por) ||
!( c3y == sec || c3n == sec ) ||
c3n == u3ud(non) ) {
if ( ( c3n == u3r_qual(tat, &sip, &por, &sec, &non) ) ||
( c3n == u3ud(sip) ) ||
( c3n == u3a_is_cat(por) ) ||
!( c3y == sec || c3n == sec ) ||
( c3n == u3ud(non) ) ) {
uL(fprintf(uH, "http: that: invalid card\n"));
u3z(tat);
return;
@ -2859,6 +2870,7 @@ u3_http_ef_that(u3_noun tat)
if ( c3n == u3_Host.ops_u.net ) {
cli_u->ipf_w = INADDR_LOOPBACK;
_proxy_ward_connect(cli_u);
u3z(tat);
return;
}