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

panic: character was not a valid digit #2717

Closed
langston-barrett opened this issue Mar 21, 2023 · 1 comment
Closed

panic: character was not a valid digit #2717

langston-barrett opened this issue Mar 21, 2023 · 1 comment
Assignees
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics E-Medium Medium difficulty problem

Comments

@langston-barrett
Copy link

Found with tree-crasher on 0e01a74.

SDPUtils = {};

SDPUtils.generateIdentifier = function() {
   Math.random()
    .toString(36)
    .substr(2, 10);
};

SDPUtils.localCName = SDPUtils.generateIdentifier();

The panic doesn't always happen.

{

}
undefined
{
length: 0,
name: "",
prototype: {
constructor: [Cycle]
    }
}
undefined
thread 'main' panicked at 'character was not a valid digit', boa_engine/src/builtins/number/mod.rs:594:34
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:64:14
   2: core::panicking::panic_display
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:147:5
   3: core::panicking::panic_str
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:131:5
   4: core::option::expect_failed
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/option.rs:1924:5
   5: boa_engine::builtins::number::Number::to_string
   6: boa_engine::vm::code_block::<impl boa_engine::object::jsobject::JsObject>::call_internal
   7: boa_engine::object::internal_methods::function::function_call{{reify.shim}}
   8: <boa_engine::vm::opcode::call::Call as boa_engine::vm::opcode::Operation>::execute
   9: boa_engine::vm::<impl boa_engine::context::Context>::run
  10: boa_engine::vm::code_block::<impl boa_engine::object::jsobject::JsObject>::call_internal
  11: boa_engine::object::internal_methods::function::function_call{{reify.shim}}
  12: <boa_engine::vm::opcode::call::Call as boa_engine::vm::opcode::Operation>::execute
  13: boa_engine::vm::<impl boa_engine::context::Context>::run
  14: boa_engine::context::Context::execute
  15: boa_engine::context::Context::eval_script
  16: boa::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@langston-barrett langston-barrett added the bug Something isn't working label Mar 21, 2023
@vfosnar
Copy link

vfosnar commented Apr 8, 2023

Math.random().toString(radix); sometimes crashes for radix > 16. It looks like it never happens for radix <= 16.

reproducible with

while (true) {
    Math.random().toString(17);
}

@jedel1043 jedel1043 added the builtins PRs and Issues related to builtins/intrinsics label Apr 8, 2023
@jasonwilliams jasonwilliams added the E-Medium Medium difficulty problem label Apr 12, 2023
@HalidOdat HalidOdat self-assigned this Apr 23, 2023
@bors bors bot closed this as completed in 49e39d4 Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics E-Medium Medium difficulty problem
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants