Skip to content

Conversation

@pazz
Copy link
Collaborator

@pazz pazz commented May 28, 2025

This is a parametric example where in nfa-n one can control at most $2^n$ tokens.

nfa-3

This exposes a few bugs: first, shephert simply dies on nfa-3.dot.

> shepherd -f dot nfa-3.dot 
memory allocation of 234930447648 bytes failed

How very unRusty!
@Numero7 do have a look!

The second issue is that according to the logs running the prism iterator, these nfas are not complete. But they are!

@pazz pazz force-pushed the iterative-majority branch from b038f66 to 098c9c1 Compare May 28, 2025 14:59
@pazz
Copy link
Collaborator Author

pazz commented May 28, 2025

(The second bug has now been fixed in #94)

@pazz
Copy link
Collaborator Author

pazz commented May 28, 2025

Regarding the memory allocation issue, the following may help to debug.

I ran this command in gdb (prefix the command with gdb --args, type r to run, then type bt to print the back trace. HEre is what it gives.

 gdb --args ./target/debug/shepherd -f dot examples/iterated-majority/nfa-3.dot 
GNU gdb (Debian 16.3-1) 16.3
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./target/debug/shepherd...
warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /home/patrick/projects/shepherd/target/debug/shepherd.
Use `info auto-load python-scripts [REGEXP]' to list them.
(gdb) r
Starting program: /home/patrick/projects/shepherd/target/debug/shepherd -f dot examples/iterated-majority/nfa-3.dot
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7c866c0 (LWP 24236)]
[New Thread 0x7ffff7a856c0 (LWP 24237)]
[New Thread 0x7ffff78846c0 (LWP 24238)]
[New Thread 0x7ffff76836c0 (LWP 24239)]
memory allocation of 234930447648 bytes failed

Thread 1 "shepherd" received signal SIGABRT, Aborted.
0x00007ffff7e3a95c in ?? () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0  0x00007ffff7e3a95c in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff7de5cc2 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007ffff7dce4ac in abort () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x0000555555f1f31a in std::sys::pal::unix::abort_internal () at library/std/src/sys/pal/unix/mod.rs:374
#4  0x00005555556f641a in std::process::abort () at library/std/src/process.rs:2375
#5  0x0000555555f32421 in std::alloc::rust_oom (layout=...) at library/std/src/alloc.rs:376
#6  0x0000555555f32443 in std::alloc::_::__rg_oom (size=0, align=24233) at library/std/src/alloc.rs:371
#7  0x00005555556f6d50 in alloc::alloc::handle_alloc_error::rt_error (layout=...) at library/alloc/src/alloc.rs:403
#8  alloc::alloc::handle_alloc_error (layout=...) at library/alloc/src/alloc.rs:409
#9  0x00005555556f6d3d in alloc::raw_vec::handle_error (e=...) at library/alloc/src/raw_vec.rs:792
#10 0x0000555555ae1ed0 in alloc::raw_vec::RawVecInner<alloc::alloc::Global>::with_capacity_in<alloc::alloc::Global> (capacity=9788768652, alloc=..., elem_layout=...)
    at /usr/src/rustc-1.85.0/library/alloc/src/raw_vec.rs:428
#11 0x00005555557602fc in alloc::raw_vec::RawVec<shepherd::ideal::Ideal, alloc::alloc::Global>::with_capacity_in<shepherd::ideal::Ideal, alloc::alloc::Global> (capacity=9788768652)
    at /usr/src/rustc-1.85.0/library/alloc/src/raw_vec.rs:192
#12 alloc::vec::Vec<shepherd::ideal::Ideal, alloc::alloc::Global>::with_capacity_in<shepherd::ideal::Ideal, alloc::alloc::Global> (capacity=9788768652)
    at /usr/src/rustc-1.85.0/library/alloc/src/vec/mod.rs:803
#13 alloc::vec::Vec<shepherd::ideal::Ideal, alloc::alloc::Global>::with_capacity<shepherd::ideal::Ideal> (capacity=9788768652) at /usr/src/rustc-1.85.0/library/alloc/src/vec/mod.rs:483
#14 alloc::vec::spec_from_iter_nested::{impl#0}::from_iter<shepherd::ideal::Ideal, core::iter::adapters::map::Map<itertools::adaptors::multi_product::MultiProduct<alloc::vec::into_iter::IntoIter<shepherd::coef::Coef, alloc::alloc::Global>>, fn(alloc::vec::Vec<shepherd::coef::Coef, alloc::alloc::Global>) -> shepherd::ideal::Ideal>> (iterator=...)
    at /usr/src/rustc-1.85.0/library/alloc/src/vec/spec_from_iter_nested.rs:31
#15 0x0000555555771ffe in alloc::vec::spec_from_iter::{impl#0}::from_iter<shepherd::ideal::Ideal, core::iter::adapters::map::Map<itertools::adaptors::multi_product::MultiProduct<alloc::vec::into_iter::IntoIter<shepherd::coef::Coef, alloc::alloc::Global>>, fn(alloc::vec::Vec<shepherd::coef::Coef, alloc::alloc::Global>) -> shepherd::ideal::Ideal>> (
    iterator=<error reading variable: Cannot access memory at address 0x5ea9>) at /usr/src/rustc-1.85.0/library/alloc/src/vec/spec_from_iter.rs:34
#16 0x0000555555770c21 in alloc::vec::{impl#15}::from_iter<shepherd::ideal::Ideal, core::iter::adapters::map::Map<itertools::adaptors::multi_product::MultiProduct<alloc::vec::into_iter::IntoIter<shepherd::coef::Coef, alloc::alloc::Global>>, fn(alloc::vec::Vec<shepherd::coef::Coef, alloc::alloc::Global>) -> shepherd::ideal::Ideal>> (iter=...)
    at /usr/src/rustc-1.85.0/library/alloc/src/vec/mod.rs:3427
#17 0x0000555555811465 in core::iter::traits::iterator::Iterator::collect<core::iter::adapters::map::Map<itertools::adaptors::multi_product::MultiProduct<alloc::vec::into_iter::IntoIter<shepherd::coef::Coef, alloc::alloc::Global>>, fn(alloc::vec::Vec<shepherd::coef::Coef, alloc::alloc::Global>) -> shepherd::ideal::Ideal>, alloc::vec::Vec<shepherd::ideal::Ideal, alloc::alloc::Global>> (self=<error reading variable: Cannot access memory at address 0x5ea9>) at /usr/src/rustc-1.85.0/library/core/src/iter/traits/iterator.rs:1971
#18 0x00005555557b25a3 in shepherd::downset::POSSIBLE_COEFS_CACHE::{closure#0}::{closure#0} (possible_coefs=0x7fffffffc670) at src/downset.rs:43
#19 0x000055555579b68f in core::ops::function::FnOnce::call_once<shepherd::downset::POSSIBLE_COEFS_CACHE::{closure#0}::{closure_env#0}, (&alloc::vec::Vec<alloc::vec::Vec<shepherd::coef::Coef, alloc::alloc::Global>, alloc::alloc::Global>)> () at /usr/src/rustc-1.85.0/library/core/src/ops/function.rs:250
#20 0x0000555555799d3f in core::ops::function::Fn::call<fn(&alloc::vec::Vec<alloc::vec::Vec<shepherd::coef::Coef, alloc::alloc::Global>, alloc::alloc::Global>) -> alloc::vec::Vec<shepherd::ideal::Ideal, alloc::alloc::Global>, (&alloc::vec::Vec<alloc::vec::Vec<shepherd::coef::Coef, alloc::alloc::Global>, alloc::alloc::Global>)> ()
    at /usr/src/rustc-1.85.0/library/core/src/ops/function.rs:79
#21 0x00005555557e7764 in shepherd::memoizer::Memoizer<alloc::vec::Vec<alloc::vec::Vec<shepherd::coef::Coef, alloc::alloc::Global>, alloc::alloc::Global>, alloc::vec::Vec<shepherd::ideal::Ideal, alloc::alloc::Global>, fn(&alloc::vec::Vec<alloc::vec::Vec<shepherd::coef::Coef, alloc::alloc::Global>, alloc::alloc::Global>) -> alloc::vec::Vec<shepherd::ideal::Ideal, alloc::alloc::Global>>::get<alloc::vec::Vec<alloc::vec::Vec<shepherd::coef::Coef, alloc::alloc::Global>, alloc::alloc::Global>, alloc::vec::Vec<shepherd::ideal::Ideal, alloc::alloc::Global>, fn(&alloc::vec::Vec<alloc::vec::Vec<shepherd::coef::Coef, alloc::alloc::Global>, alloc::alloc::Global>) -> alloc::vec::Vec<shepherd::ideal::Ideal, alloc::alloc::Global>> (
    self=0x555556371088 <shepherd::downset::POSSIBLE_COEFS_CACHE+24>, key=...) at src/memoizer.rs:31
#22 0x00005555557952c3 in shepherd::downset::DownSet::safe_pre_image (self=0x7fffffffcda0, edges=0x555556373878, maximal_finite_coordinate=11) at src/downset.rs:304
#23 0x000055555578904f in shepherd::strategy::Strategy::restrict_to (self=0x7fffffffcf58, safe=..., edges_per_letter=0x7fffffffd3c0, maximal_finite_value=11) at src/strategy.rs:43
#24 0x00005555557568f1 in shepherd::solver::update_strategy (dim=11, strategy=0x7fffffffcf58, final_states=..., edges=0x7fffffffd3c0, maximal_finite_value=11) at src/solver.rs:140
#25 0x0000555555755844 in shepherd::solver::compute_maximal_winning_strategy (dim=11, final_states=..., edges=..., letters=...) at src/solver.rs:62
#26 0x00005555557553c4 in shepherd::solver::solve (nfa=0x7fffffffd690, output=0x7fffffffd669) at src/solver.rs:31
#27 0x00005555556f7a97 in shepherd::main () at src/main.rs:27
(gdb) ```

@Numero7
Copy link
Collaborator

Numero7 commented May 28, 2025

@pazz lot of memory is needed onnfa-3.dot , I will investigate

image

@pazz pazz merged commit ef0eb1f into main May 29, 2025
4 checks passed
@pazz pazz deleted the iterative-majority branch May 29, 2025 15:23
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