<div dir="ltr">If your code runs on OSX but fails on Linux, it's likely you have an issue accessing invalid memory. You should run valgrind or compile with -fsanitize=address to help you find your error. There are also many working example and test programs as part of the PDAL distribution that may help.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 27, 2021 at 6:46 AM Peder Axensten <<a href="mailto:Peder.Axensten@slu.se">Peder.Axensten@slu.se</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I’m in the process of changing from liblas to pdal and all our tools but one have now – with great help from this list! – been converted into pdal filters. The remaining tool reads all las/laz-files in a given directory. I have not yet figured out a good way to make it fit into the pdal filter paradigm, so for now I’ll keep the tool, but switch the file reading from liblas to pdal. I found information on how to do this at <a href="https://pdal.io/api/transition/index.html" rel="noreferrer" target="_blank">https://pdal.io/api/transition/index.html</a>. I put the specific code into the class Point_file_reader, as seen below. It runs perfectly on OS X, but we process data in Ubuntu under Docker and this crashes under certain circumstances...<br>
<br>
If I simply construct a Point_file_reader object all works fine also in Ubuntu, but used in the processing environment it crashes with SIGSEGV - Segmentation violation signal. I really can not see how the processing environment could affect this isolated code as there are no apparent dependencies apart from the file path, but I’m obviously wrong. My next step will be to simplify until the crash goes away, but as this is rather cumbersome I first want to ask this list if someone have had similar experiences?<br>
<br>
The crash happens in laszip, called by pdal (as seen further below). In OS X I use clang, in Ubuntu I use gcc. The versions of pdal and laszip are as of last week.<br>
<br>
Any insights or ideas will be much appreciated!<br>
<br>
==============================<br>
#pragma once<br>
<br>
#include <filesystem><br>
#include <memory><br>
#include <pdal/PointTable.hpp><br>
#include <pdal/PointView.hpp><br>
#include <pdal/io/LasHeader.hpp><br>
#include <pdal/io/LasReader.hpp><br>
#include <pdal/Options.hpp><br>
<br>
namespace pax {<br>
<br>
/// Open an aprs las file (possibly compressed).<br>
/** Code from <a href="https://pdal.io/api/transition/index.html**/" rel="noreferrer" target="_blank">https://pdal.io/api/transition/index.html**/</a><br>
class Point_file_reader {<br>
pdal::LasReaderm_reader{};<br>
pdal::PointTablem_table{};<br>
pdal::PointViewSetm_point_view_set{};<br>
pdal::PointViewPtrm_point_view{};<br>
<br>
public:<br>
using point_type = pdal::PointRef;<br>
using header_type = pdal::LasHeader;<br>
using Id = pdal::Dimension::Id;<br>
<br>
Point_file_reader( const std::filesystem::path & file_ ) {<br>
pdal::Optionoption( "filename", file_.native() );<br>
pdal::Optionsoptions;<br>
options.add( option );<br>
m_reader.setOptions( options );<br>
m_reader.prepare( m_table );<br>
<br>
// Next line in Ubuntu 20.10 under Docker: SIGSEGV - Segmentation violation signal<br>
m_point_view_set = pdal::PointViewSet{ m_reader.execute( m_table ) };<br>
<br>
m_point_view = pdal::PointViewPtr{ *m_point_view_set.begin() };<br>
}<br>
<br>
const header_type & header() const {return m_reader.header();}<br>
auto begin() const {return m_point_view->begin();}<br>
auto end() const {return m_point_view->end();}<br>
bool has_dim( const Id dim_)const {return m_point_view->hasDim( dim_ );}<br>
};<br>
<br>
}//namespace pax<br>
==============================<br>
<br>
I’ve installed gdb in the Docker environment, but I’m not very familiar with it. This is what I get:<br>
<br>
==============================<br>
(gdb) run<br>
Starting program: /pax/build/Linux/point-cloud<br>
warning: Error disabling address space randomization: Operation not permitted<br>
[Thread debugging using libthread_db enabled]<br>
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".<br>
[doctest] run with "--help" for options<br>
<br>
Program received signal SIGSEGV, Segmentation fault.<br>
0x00007f55095c5cbd in std::istream::read(char*, long) () from /lib/x86_64-linux-gnu/libstdc++.so.6<br>
(gdb) up<br>
#1 0x00007f5509118ee3 in ByteStreamInIstream::getBytes(unsigned char*, unsigned int) () from /usr/local/lib/liblaszip.so.6<br>
(gdb) up<br>
#2 0x00007f5506055b73 in laszip_read_header (laszip_dll=0x557806355e30, is_compressed=0x7ffd6e735354) at /tmp/LASzip/src/laszip_dll.cpp:3454<br>
3454 try { laszip_dll->streamin->getBytes((U8*)file_signature, 4); } catch(...)<br>
(gdb) up<br>
#3 0x00007f5506059c44 in laszip_open_reader_stream (pointer=0x557806355e30, stream=..., is_compressed=is_compressed@entry=0x7ffd6e735354)<br>
at /tmp/LASzip/src/laszip_dll.cpp:4810<br>
4810 return laszip_read_header(laszip_dll, is_compressed);<br>
(gdb) up<br>
#4 0x00007f5509a817d0 in pdal::LasReader::ready (this=0x7ffd6e7359c0, table=...) at /usr/include/c++/10/bits/unique_ptr.h:421<br>
421 get() const noexcept<br>
(gdb) up<br>
#5 0x00007f5509bb75c9 in pdal::Stage::execute (this=0x7ffd6e735ac0, table=..., views=std::set with 1 element = {...}) at /usr/include/c++/10/ext/atomicity.h:84<br>
84 return __exchange_and_add(__mem, __val);<br>
(gdb) up<br>
#6 0x00007f5509bb7d7d in pdal::Stage::execute (this=<optimized out>, table=...) at /tmp/PDAL/pdal/Stage.cpp:235<br>
235 outViews = si.m_stage->execute(table, inViews);<br>
(gdb) up<br>
#7 0x0000557805cad5c8 in pax::Process_plots<pax::Aggregator_set<pax::Filtered_summary<float, 0u, pax::filter::Pass_all_filter>, pax::Filtered_summary<float, 4u, pax::filter::All_ge_level_filter>, pax::Filtered_summary<float, 0u, pax::filter::First_return_filter>, pax::Filtered_summary<float, 0u, pax::filter::First_return_ge_level_filter>, pax::Filtered_ordered<float, pax::filter::All_ge_level_filter, std::allocator<float> > > >::process_file (this=this@entry=0x7ffd6e735e80,<br>
file_=filesystem::path "../../doctests-data/point-cloud/original/09D037_68200_5175_25.laz" = {...}) at /usr/include/c++/10/ostream:517<br>
517 operator<<(basic_ostream<char, _Traits>& __out, char __c)<br>
(gdb) up<br>
#8 0x0000557805caf12e in pax::Process_plots<pax::Aggregator_set<pax::Filtered_summary<float, 0u, pax::filter::Pass_all_filter>, pax::Filtered_summary<float, 4u, pax::filter::All_ge_level_filter>, pax::Filtered_summary<float, 0u, pax::filter::First_return_filter>, pax::Filtered_summary<float, 0u, pax::filter::First_return_ge_level_filter>, pax::Filtered_ordered<float, pax::filter::All_ge_level_filter, std::allocator<float> > > >::process_directory (this=this@entry=0x7ffd6e735e80,<br>
pc_directory_=filesystem::path "../../doctests-data/point-cloud/original" = {...}) at /usr/include/c++/10/bits/fs_dir.h:161<br>
161 operator const filesystem::path& () const noexcept { return _M_path; }<br>
(gdb) up<br>
#9 0x0000557805caf5c5 in pax::process_plots<pax::Aggregator_set<pax::Filtered_summary<float, 0u, pax::filter::Pass_all_filter>, pax::Filtered_summary<float, 4u, pax::filter::All_ge_level_filter>, pax::Filtered_summary<float, 0u, pax::filter::First_return_filter>, pax::Filtered_summary<float, 0u, pax::filter::First_return_ge_level_filter>, pax::Filtered_ordered<float, pax::filter::All_ge_level_filter, std::allocator<float> > > > (pc_count_=0, do_progress_=<optimized out>,<br>
nilsson_=<optimized out>, pc_directory_=filesystem::path "../../doctests-data/point-cloud/original" = {...},<br>
plots_dest_=filesystem::path "/tmp/plots_result.csv" = {...}, plots_source_=filesystem::path "/tmp/plots_result.csv" = {...}, accessor_set_=...)<br>
at /pax/include/point-cloud/process/plot-metrics-implementation.hpp:190<br>
190Json_value process_plots(<br>
(gdb) up<br>
#10 pax::process_plots<std::filesystem::__cxx11::path const&, std::filesystem::__cxx11::path const&, std::filesystem::__cxx11::path const&, double, bool> (<br>
accessor_ref_set_=...) at /pax/include/point-cloud/process/plot-metrics-implementation.hpp:219<br>
219return process_plots( std::move( accessor_set ), std::forward< Args >( args_ )... );<br>
(gdb) up<br>
#11 0x0000557805c7f877 in pax::_DOCTEST_ANON_FUNC_4 () at /usr/include/c++/10/bits/stl_iterator.h:953<br>
953 __normal_iterator(const _Iterator& __i) _GLIBCXX_NOEXCEPT<br>
(gdb) up<br>
#12 0x0000557805cc89b8 in doctest::Context::run (this=0x7ffd6e736980) at /pax/include/3rd-party/doctest/doctest.h:6486<br>
6486 tc.m_test();<br>
(gdb) up<br>
#13 0x0000557805bf059c in main (argc=1, argv=0x7ffd6e736a98) at /pax/doctests-src/main.doctest.cpp:42<br>
42const auto test_result = context.run();<br>
(gdb) up<br>
Initial frame selected; you cannot go up.<br>
==============================<br>
<br>
<br>
Best regards,<br>
<br>
Peder Axensten<br>
Research engineer<br>
<br>
Remote Sensing<br>
Department of Forest Resource Management<br>
Swedish University of Agricultural Sciences<br>
SE-901 83 Umeå<br>
Visiting address: Skogsmarksgränd<br>
Phone: +46 90 786 85 00<br>
<a href="mailto:peder.axensten@slu.se" target="_blank">peder.axensten@slu.se</a>, <a href="http://www.slu.se/srh" rel="noreferrer" target="_blank">www.slu.se/srh</a><br>
<br>
The Department of Forest Resource Management is environmentally certified in accordance with ISO 14001.<br>
<br>
---<br>
När du skickar e-post till SLU så innebär detta att SLU behandlar dina personuppgifter. För att läsa mer om hur detta går till, klicka här <<a href="https://www.slu.se/om-slu/kontakta-slu/personuppgifter/" rel="noreferrer" target="_blank">https://www.slu.se/om-slu/kontakta-slu/personuppgifter/</a>><br>
E-mailing SLU will result in SLU processing your personal data. For more information on how this is done, click here <<a href="https://www.slu.se/en/about-slu/contact-slu/personal-data/" rel="noreferrer" target="_blank">https://www.slu.se/en/about-slu/contact-slu/personal-data/</a>><br>
_______________________________________________<br>
pdal mailing list<br>
<a href="mailto:pdal@lists.osgeo.org" target="_blank">pdal@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/pdal" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/pdal</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Andrew Bell<br><a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a></div>