Skip to content

Commit

Permalink
Bail out when list of lists limit is reached (#52)
Browse files Browse the repository at this point in the history
Previously it was silently not appending anything, what also was leading to silently dropping rule parameters.
  • Loading branch information
Kojoley authored Jul 12, 2021
1 parent ab2c3a1 commit 5731edb
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
10 changes: 4 additions & 6 deletions src/build/configure.jam
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ rule find-builds ( what : properties * : * )
return [ find-builds-raw $(p) : $(ps) : $(what) :
$(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) :
$(10) : $(11) : $(12) : $(13) : $(14) : $(15) :
$(16) : $(17) : $(18) : $(19) ] ;
$(16) : $(17) : $(18) ] ;
}


Expand Down Expand Up @@ -531,7 +531,7 @@ class configure-choose-worker
{
local project = [ project.current ] ;
self.message = $(message) ;
for i in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
for i in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
{
local name = [ CALC $(i) - 1 ] ;
self.targets.$(name) = $($(i)[1]) ;
Expand All @@ -550,7 +550,7 @@ class configure-choose-worker
}
rule all-properties ( )
{
local i = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ;
local i = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ;
return $(self.props.$(i)) ;
}
rule check ( properties * )
Expand All @@ -572,9 +572,7 @@ class configure-choose-worker
: $(self.targets.14) $(self.what.14)
: $(self.targets.15) $(self.what.15)
: $(self.targets.16) $(self.what.16)
: $(self.targets.17) $(self.what.17)
: $(self.targets.18) $(self.what.18)
: $(self.targets.19) $(self.what.19) ] ;
: $(self.targets.17) $(self.what.17) ] ;
if $(self.props.$(i))
{
return [ property.evaluate-conditionals-in-context $(self.props.$(i)) : $(properties) ] ;
Expand Down
14 changes: 14 additions & 0 deletions src/engine/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,13 @@ static LIST * function_call_rule( JAM_FUNCTION * function, FRAME * frame,
inner->prev_user = frame->module->user_module ? frame : frame->prev_user;
inner->module = frame->module; /* This gets fixed up in evaluate_rule(). */

if ( n_args > LOL_MAX )
{
out_printf( "ERROR: rules are limited to %d arguments\n", LOL_MAX );
backtrace( inner );
exit( EXITBAD );
}

for ( i = 0; i < n_args; ++i )
lol_add( inner->args, stack_at( s, n_args - i - 1 ) );

Expand Down Expand Up @@ -569,6 +576,13 @@ static LIST * function_call_member_rule( JAM_FUNCTION * function, FRAME * frame,
inner->prev_user = frame->module->user_module ? frame : frame->prev_user;
inner->module = frame->module; /* This gets fixed up in evaluate_rule(), below. */

if ( n_args > LOL_MAX )
{
out_printf( "ERROR: member rules are limited to %d arguments\n", LOL_MAX );
backtrace( inner );
exit( EXITBAD );
}

for( i = 0; i < n_args; ++i )
{
lol_add( inner->args, stack_at( s, n_args - i - 1 ) );
Expand Down
6 changes: 6 additions & 0 deletions src/engine/lists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,13 @@ void lol_init( LOL * lol )
void lol_add( LOL * lol, LIST * l )
{
if ( lol->count < LOL_MAX )
{
lol->list[ lol->count++ ] = l;
return;
}

err_printf( "lol_add failed due to reached limit of %d elements\n", LOL_MAX );
exit( EXITBAD );
}


Expand Down
3 changes: 1 addition & 2 deletions src/kernel/modules.jam
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ rule call-in ( module-name ? : rule-name args * : * )
module $(module-name)
{
return [ $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) : $(10) :
$(11) : $(12) : $(13) : $(14) : $(15) : $(16) : $(17) : $(18) :
$(19) ] ;
$(11) : $(12) : $(13) : $(14) : $(15) : $(16) : $(17) : $(18) ] ;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/indirect.jam
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ rule call ( [indirect-rule] r args * : * )
{
return [ modules.call-in [ get-module $(r) ] : [ get-rule $(r) ] $(args) :
$(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) : $(10) : $(11) :
$(12) : $(13) : $(14) : $(15) : $(16) : $(17) : $(18) : $(19) ] ;
$(12) : $(13) : $(14) : $(15) : $(16) : $(17) : $(18) ] ;
}

.parts_regex = "^([^@]*)@" "([^%]*)%" "([^%]+)$" ;
Expand Down
2 changes: 2 additions & 0 deletions test/core_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ def test_varargs(t, *args, **kwargs):
expected = "a= 1 b= c= : d= 2 : e= 3 : rest= " + simple_args(4, 19)
test_varargs(t, simple_args(1, 19), expected)
test_varargs(t, simple_args(1, 19) + " 19b 19c 19d", expected + " 19b 19c 19d")
'''FIXME: 19 (=LOL_MAX) args is the limit
test_varargs(t, simple_args(1, 19) + " 19b 19c 19d : 20", expected + " 19b "
"19c 19d")
test_varargs(t, simple_args(1, 20), expected)
test_varargs(t, simple_args(1, 50), expected)
'''

t.cleanup()

0 comments on commit 5731edb

Please sign in to comment.