Skip to content

Conversation

@klayoutmatthias
Copy link
Collaborator

No description provided.

@martinjankoehler
Copy link
Contributor

martinjankoehler commented May 21, 2025

@klayoutmatthias debugability of the RExtractorTech from Python could be improved, currently it's impossible to print or look into the variable

<klayout.pexcore.RExtractorTech object at 0x1090edd50>

@martinjankoehler
Copy link
Contributor

@klayoutmatthias I've obtained a segmentation fault

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Python [31946]
Path:                  /opt/homebrew/*/Python.framework/Versions/3.12/Resources/Python.app/Contents/MacOS/Python
Identifier:            org.python.python
Version:               3.12.10 (3.12.10)
Code Type:             ARM-64 (Native)
Parent Process:        pycharm [1402]
Responsible:           pycharm [1402]
User ID:               501

Date/Time:             2025-05-22 16:27:28.9469 +0200
OS Version:            macOS 15.5 (24F74)
Report Version:        12
Anonymous UUID:        7ACC797B-51F1-BF61-2F14-6473FFCEB8C2


Time Awake Since Boot: 6000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000008
Exception Codes:       0x0000000000000001, 0x0000000000000008

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [31946]

VM Region Info: 0x8 is not in any region.  Bytes before following region: 4303634424
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      100844000-100848000    [   16K] r-x/r-x SM=COW  /opt/homebrew/*/Python.framework/Versions/3.12/Resources/Python.app/Contents/MacOS/Python

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   lib_db.cpython-312-darwin.so  	       0x10ba5d5fc db::plc::Edge::other(db::plc::Vertex const*) const + 0 (dbPLC.cc:284) [inlined]
1   lib_db.cpython-312-darwin.so  	       0x10ba5d5fc db::plc::Polygon::init() + 1596 (dbPLC.cc:465)
2   lib_db.cpython-312-darwin.so  	       0x10ba691d4 0x10b200000 + 8819156
3   lib_db.cpython-312-darwin.so  	       0x10ba62ff4 db::plc::Polygon::Polygon<std::__1::__hash_const_iterator<std::__1::__hash_node<db::plc::Edge*, void*>*>>(db::plc::Graph*, std::__1::__hash_const_iterator<std::__1::__hash_node<db::plc::Edge*, void*>*>, std::__1::__hash_const_iterator<std::__1::__hash_node<db::plc::Edge*, void*>*>) + 16 (dbPLC.h:769) [inlined]
4   lib_db.cpython-312-darwin.so  	       0x10ba62ff4 db::plc::Polygon* db::plc::Graph::create_polygon<std::__1::__hash_const_iterator<std::__1::__hash_node<db::plc::Edge*, void*>*>>(std::__1::__hash_const_iterator<std::__1::__hash_node<db::plc::Edge*, void*>*>, std::__1::__hash_const_iterator<std::__1::__hash_node<db::plc::Edge*, void*>*>) + 28 (dbPLC.h:878) [inlined]
5   lib_db.cpython-312-darwin.so  	       0x10ba62ff4 db::plc::ConvexDecomposition::hertel_mehlhorn_decomposition(db::plc::Triangulation&, db::plc::ConvexDecompositionParameters const&) + 4576 (dbPLCConvexDecomposition.cc:417)
6   lib_db.cpython-312-darwin.so  	       0x10ba63a0c db::plc::ConvexDecomposition::decompose(db::polygon<int> const&, std::__1::vector<db::point<int>, std::__1::allocator<db::point<int>>> const&, db::plc::ConvexDecompositionParameters const&, db::complex_trans<int, double, double> const&) + 96 (dbPLCConvexDecomposition.cc:453)
7   lib_pex.cpython-312-darwin.so 	       0x106643670 pex::SquareCountingRExtractor::extract(db::polygon<int> const&, std::__1::vector<db::point<int>, std::__1::allocator<db::point<int>>> const&, std::__1::vector<db::polygon<int>, std::__1::allocator<db::polygon<int>>> const&, pex::RNetwork&) + 300 (pexSquareCountingRExtractor.cc:191)
8   lib_pex.cpython-312-darwin.so 	       0x106639040 0x106600000 + 233536
9   lib_pex.cpython-312-darwin.so 	       0x106635608 bool db::box_scanner2<db::polygon<int>, unsigned long, db::box<int, int>, unsigned long>::do_process<pex::(anonymous namespace)::ExtractingReceiver, db::box_convert<db::polygon<int>, true>, db::box_convert<db::box<int, int>, true>>(pex::(anonymous namespace)::ExtractingReceiver&, db::box_convert<db::polygon<int>, true>::box_type::coord_type, db::box_convert<db::polygon<int>, true> const&, db::box_convert<db::box<int, int>, true> const&) + 28 (dbBoxScanner.h:749) [inlined]
10  lib_pex.cpython-312-darwin.so 	       0x106635608 bool db::box_scanner2<db::polygon<int>, unsigned long, db::box<int, int>, unsigned long>::process<pex::(anonymous namespace)::ExtractingReceiver, db::box_convert<db::polygon<int>, true>, db::box_convert<db::box<int, int>, true>>(pex::(anonymous namespace)::ExtractingReceiver&, db::box_convert<db::polygon<int>, true>::box_type::coord_type, db::box_convert<db::polygon<int>, true> const&, db::box_convert<db::box<int, int>, true> const&) + 28 (dbBoxScanner.h:681) [inlined]
11  lib_pex.cpython-312-darwin.so 	       0x106635608 pex::RNetExtractor::extract_conductor(pex::RExtractorTechConductor const&, db::Region const&, std::__1::vector<db::point<int>, std::__1::allocator<db::point<int>>> const&, std::__1::vector<db::polygon<int>, std::__1::allocator<db::polygon<int>>> const&, std::__1::vector<pex::RNetExtractor::ViaPort, std::__1::allocator<pex::RNetExtractor::ViaPort>> const&, pex::RNetwork&) + 2180 (pexRNetExtractor.cc:473)
12  lib_pex.cpython-312-darwin.so 	       0x106634324 pex::RNetExtractor::extract(pex::RExtractorTech const&, std::__1::map<unsigned int, db::Region, std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<unsigned int const, db::Region>>> const&, std::__1::map<unsigned int, std::__1::vector<db::point<int>, std::__1::allocator<db::point<int>>>, std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<unsigned int const, std::__1::vector<db::point<int>, std::__1::allocator<db::point<int>>>>>> const&, std::__1::map<unsigned int, std::__1::vector<db::polygon<int>, std::__1::allocator<db::polygon<int>>>, std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<unsigned int const, std::__1::vector<db::polygon<int>, std::__1::allocator<db::polygon<int>>>>>> const&, pex::RNetwork&) + 516 (pexRNetExtractor.cc:88)
13  lib_pex.cpython-312-darwin.so 	       0x10660ce9c 0x106600000 + 52892
14  lib_pex.cpython-312-darwin.so 	       0x10661ad60 0x106600000 + 109920
15  lib_pya.cpython-312-darwin.so 	       0x104e1ea74 0x104e08000 + 92788
16  Python                        	       0x101009d80 method_vectorcall_VARARGS_KEYWORDS + 148
17  Python                        	       0x1010f3414 _PyEval_EvalFrameDefault + 42244
18  Python                        	       0x1010e8ca0 PyEval_EvalCode + 184
…

@martinjankoehler
Copy link
Contributor

martinjankoehler commented May 22, 2025

@klayoutmatthias

If I attach the Debugger, it seems that i->second is null in dbPLC.cc:465.

After v2e.erase(i);, the iterator is invalid,
so it's not a good idea to further use it in the lines below.

Bildschirmfoto 2025-05-22 um 17 23 52

@martinjankoehler
Copy link
Contributor

@klayoutmatthias ok, I built a version where the iterator erasal is moved to the point where the variable is reused,
this fixes the crash.

Bildschirmfoto 2025-05-22 um 17 49 58

@klayoutmatthias
Copy link
Collaborator Author

Of course! good catch :)

The change is pushed.

Thanks!

Matthias

@martinjankoehler
Copy link
Contributor

martinjankoehler commented May 22, 2025

@klayoutmatthias
How is the connectivity intended for vertex_ports?
Would we need kdb.PointWithProperties, does not seem to exist yet?

Currently, I've added kdb.Text.position() to the vertex_ports list,
but this loses the net information

So, for a wire resistor beween nets A and B, the extracted network prints as:

R V0.35 V1.35 853333

@klayoutmatthias
Copy link
Collaborator Author

Hi Martin,

the idea is that you the node carries the port index. So you know which port was meant.

In other words, you can maintain two arrays: one with the vertexes that form the ports and another one with your attributes (net name or any other data). When you investigate the node, you can get the port index and look up your attributes in the attribute array by this index.

The same is available for polygon ports too, but as a separate index.

Matthias

@klayoutmatthias klayoutmatthias merged commit 3ce5067 into master May 29, 2025
23 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants