Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Potential bug] Attempt to apply non-function #1478

@dipterix

Description

@dipterix

This bug can be reproduced using the toy example listed on your website, with shiny:

https://books.ropensci.org/targets/walkthrough.html

library(targets)
library(tarchetypes)
tar_manifest(fields = all_of("command"))

shiny::shinyApp(
  ui = shiny::actionButton("run", "run"),
  server = function(input, output, session) {
    shiny::bindEvent(
      shiny::observe({
        targets::tar_destroy(ask = FALSE)
        targets::tar_make(names = "model", callr_function = NULL)
      }),
      input$run,
      ignoreInit = TRUE
    )
  }
)
ended pipeline [51ms, 0 completed, 0 skipped]
Warning: Error in : Error in tar_make():
  attempt to apply non-function
  See https://books.ropensci.org/targets/debugging.html
  94: <Anonymous>
  93: signalCondition
  92: signal_abort
  91: rlang::abort
  90: tar_error
  89: tar_throw_run
  88: callr_error
  86: callr_outer
  85: targets::tar_make
  84: ::
shiny
observe [~/.active-rstudio-document#11]
  83: <observer>
   4: runApp
   3: print.shiny.appobj
   1: source

The reason why this bug is minor is because users are not supposed to use callr_function=NULL in normal scenarios. However, the reason why this could be a bug is because in cli package,

https://github.com/r-lib/cli/blob/main/R/progress-server.R#L356C1-L365C5

bar$shiny_progress <- NULL

bar$shiny_progress is set to NULL after completion. When the progress finishes and further attempts trying to reuse this reference will end up with "Attempt to apply non-function" error. That means, there is some use-after-freed cases in this package.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions