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

segfault when processing a catalog with "processed" tiles #22

Closed
jmmonnet opened this issue Apr 3, 2024 · 4 comments
Closed

segfault when processing a catalog with "processed" tiles #22

jmmonnet opened this issue Apr 3, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@jmmonnet
Copy link

jmmonnet commented Apr 3, 2024

Hi, I want to run a normalization (and then add dtm computation) pipeline on selected tiles of a LAScatalog. When the pipeline is run on all tiles (no processed field), the pipeline runs smoothly, but when the processed fields indicates only a subset of tiles to process, the output files are created but then R crashes with a segfault error. I have lasR 0.4.2 installed today.

Here are some files for testing:
https://filesender.renater.fr/?s=download&token=6a1fdcd3-50a2-462a-861c-79a93f85afee

The code I ran:

cata <- lidR::catalog("./las")
library(lasR)
# read catalog
read = reader(cata)
# build del
tri = triangulate(filter = "-keep_class 2 9")
# normalize
trans = transform_with(tri)
# write
write2 = write_las("./norm/*.laz")
#
# run pipeline
ans1 = exec(read + tri + trans + write2)
outputfiles <- list.files("./norm/", full.names = TRUE)
print(outputfiles)
#
# remove previous output files
unlink(outputfiles)
#
# set files to process in catalog
cata$processed <- FALSE
cata$processed[2:3] <- TRUE
# read catalog
read = reader(cata)
# run pipeline
ans1 = exec(read + tri + trans + write2)

The error I get with R ran from a console:

 *** caught segfault ***
address (nil), cause 'memory not mapped'

Traceback:
 1: processor(pipeline, ncores = with$ncores, progress = with$progress,     ...)
 2: exec(read + tri + trans + write2)
@Jean-Romain Jean-Romain self-assigned this Apr 3, 2024
@Jean-Romain Jean-Romain added the bug Something isn't working label Apr 3, 2024
@Jean-Romain
Copy link
Collaborator

Jean-Romain commented Apr 3, 2024

Will check it tomorrow. Thank you for your simple and reproducible example as usual.

MRE:

library(lasR)

f = list.files("issue 22/test/las", pattern = ".las", full.names = T)[1:2]

read = reader_las(filter = "-keep_random_fraction 0.05")
tri = triangulate(filter = "-keep_class 2 9")
trans = transform_with(tri)
write2 = write_las()
ans1 = exec(read + tri + trans + write2,  on = f, noprocess = c(T, F), progress = T, noread = TRUE)
ans1

@Jean-Romain
Copy link
Collaborator

Jean-Romain commented Apr 3, 2024

Fixed.

FYI reader(cata) is deprecated. It works with exec because I added a convenient workaround. The correct syntax is:

read = reader_las()
tri = triangulate(filter = "-keep_class 2 9")
trans = transform_with(tri)
write2 = write_las()
ans1 = exec(read + tri + trans + write2,  on = cata)

When reader_las() is called without argument, it can be omitted.

tri = triangulate(filter = "-keep_class 2 9")
trans = transform_with(tri)
write2 = write_las()
ans1 = exec(tri + trans + write2,  on = cata)

Also I'm now using r-universe. You can install pre-compiled versions of the package like on the CRAN

install.packages('lasR', repos = 'https://r-lidar.r-universe.dev')

@jmmonnet
Copy link
Author

jmmonnet commented Apr 3, 2024

Thank you for the tips and for the fix. Fast and efficient as usual !

Jean-Romain added a commit that referenced this issue Apr 4, 2024
@Jean-Romain
Copy link
Collaborator

Jean-Romain commented Apr 4, 2024

Please reinstall in an hour or two (or now with remotes::) my fix was not correct. It fixed the segfault but broke the order of the output with parallel processing. This was not caught by unit tests but it was an (un)happy accident.

Jean-Romain added a commit that referenced this issue Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants