Code Monkey home page Code Monkey logo

paper-terminal's Issues

Memory allocation of 18446744073709551614 bytes failed

When I just ran paper it printed a bit of a page and aborted (which is not a panic) with an error message:

memory allocation of 18446744073709551615 bytes failed
[2]    805646 abort (core dumped)  paper test.md

(The precise byte count varies slightly, but is generally in the realm of 2^64, indicating that it might actually be some small negative number casted e.g. from isize to usize, I have a 64-bit system. Maybe a simple saturating_sub solves this)

Version: paper 2.1.1 (via Cargo)

Backtrace Since this is an abort there is no Rust Backtrace, however, `gdb` can still help:
$ gdb paper test.md
memory allocation of 18446744073709551615 bytes failed

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7c38859 in __GI_abort () at abort.c:79
#2  0x00005555557ed207 in std::sys::unix::abort_internal ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/std/src/sys/unix/mod.rs:237
#3  0x00005555557e2b86 in std::process::abort ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/std/src/process.rs:1784
#4  0x00005555557e5a5e in std::alloc::rust_oom ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/std/src/alloc.rs:332
#5  0x00005555557fe487 in alloc::alloc::__alloc_error_handler::__rg_oom ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/alloc/src/alloc.rs:397
#6  0x00005555557fe477 in alloc::alloc::handle_alloc_error ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/alloc/src/alloc.rs:366
#7  0x00005555557ff221 in alloc::raw_vec::RawVec<T,A>::allocate_in ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/alloc/src/raw_vec.rs:206
#8  alloc::raw_vec::RawVec<T,A>::with_capacity_in ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/alloc/src/raw_vec.rs:142
#9  alloc::vec::Vec<T,A>::with_capacity_in ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/alloc/src/vec/mod.rs:574
#10 alloc::vec::Vec<T>::with_capacity ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/alloc/src/vec/mod.rs:440
#11 alloc::slice::<impl [T]>::repeat ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/alloc/src/slice.rs:534
#12 alloc::str::<impl str>::repeat ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/alloc/src/str.rs:493
#13 0x00005555555be7ce in paper::printer::Printer::handle ()
#14 0x00005555555ce6cc in paper::main ()
#15 0x00005555555c0f33 in std::sys_common::backtrace::__rust_begin_short_backtrace ()
#16 0x00005555555c0f49 in std::rt::lang_start::{{closure}} ()
#17 0x00005555557e70a7 in core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/ops/function.rs:259
#18 std::panicking::try::do_call ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/std/src/panicking.rs:379
#19 std::panicking::try ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/std/src/panicking.rs:343
#20 std::panic::catch_unwind ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/std/src/panic.rs:431
#21 std::rt::lang_start_internal ()
    at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0//library/std/src/rt.rs:51
#22 0x00005555555d1d72 in main ()

Investigating further, I tried all command line options together, just to notice, that it starts failing at a different point in the document. Which gave me the idea to extract that line:

So when using the 'plain' mode paper -p test.md this line causes the error:

[asdfg.io](https://example.org/a/veeeeery/looooooong/url/to/fail/the/plain/text)

Apparently the total length of the URL is significant for this error, but also the tag is important, e.g. this does work (same URL):

[stil-lnot-long-enou-gh.io](https://example.org/a/veeeeery/looooooong/url/to/fail/the/plain/text)

(but adding another ~3 characters to the URL, or shrinking the terminal-width makes is fail again)

Back to the 'normal' mode (paper test.md), here it seems that emojis within a code-block cause the problem:

```
๐Ÿ‘‹
```

(seriously, you need an emoji (e.g. ๐Ÿ‘‹) with in a proper code-block (the back-tick-thingy))

Also notice, that emojis in normal text and even in inline-code work, it's just code-blocks that fail.


So, it seems there are actually two (fairly) different ways to invoke this error. First a fairly long link URL in the 'plain' mode, and Unicode emojis in code-blocks in 'normal' mode. The other way around does not cause the error, e.g. a long URL in 'normal' mode works, and an emoji in a code-block works in the plain mode.

As a unified example (that fails in both cases):

# Let's make a negative allocation!

[example.io](https://example.org/a/veeeeery/looooooong/url/to/fail/the/plain/mode)

```
fails in 'normal' mode: ๐Ÿ‘‹
```

You'll never see this line.

Support YAML frontmatter

Markdown documents sometimes have YAML frontmatter at the start, which does not render nicely when piped into paper. In particular, the output of gh repo view, for example, includes this frontmatter, so gh repo view | paper does not look great at the top.

The frontmatter should be parsed and removed. It could be shown off the page, or in a table on the page, if desired (maybe put it behind a flag?).

Fails when building through `cargo install paper-terminal`

Fails with the following error:

error[E0308]: mismatched types
   --> /Users/broderickcarlin/.cargo/registry/src/github.com-1ecc6299db9ec823/paper-terminal-0.3.0/src/printer.rs:216:9
    |
211 |     fn style3(&self, extra_scopes: Option<&[&str]>, token: Option<&str>) -> Style {
    |                                                                             ----- expected `ansi_term::style::Style` because of return type
...
216 |         self.stylesheet.resolve_basic(&scope_names, token).build()
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `ansi_term::style::Style`, found a different struct `ansi_term::style::Style`
    |
    = note: expected type `ansi_term::style::Style` (struct `ansi_term::style::Style`)
               found type `ansi_term::style::Style` (struct `ansi_term::style::Style`)
note: Perhaps two different versions of crate `ansi_term` are being used?
   --> /Users/broderickcarlin/.cargo/registry/src/github.com-1ecc6299db9ec823/paper-terminal-0.3.0/src/printer.rs:216:9
    |
216 |         self.stylesheet.resolve_basic(&scope_names, token).build()
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> /Users/broderickcarlin/.cargo/registry/src/github.com-1ecc6299db9ec823/paper-terminal-0.3.0/src/printer.rs:232:9
    |
231 |     fn paper_style(&self) -> Style {
    |                              ----- expected `ansi_term::style::Style` because of return type
232 |         self.stylesheet.resolve_basic(&["paper"], None).build()
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `ansi_term::style::Style`, found a different struct `ansi_term::style::Style`
    |
    = note: expected type `ansi_term::style::Style` (struct `ansi_term::style::Style`)
               found type `ansi_term::style::Style` (struct `ansi_term::style::Style`)
note: Perhaps two different versions of crate `ansi_term` are being used?
   --> /Users/broderickcarlin/.cargo/registry/src/github.com-1ecc6299db9ec823/paper-terminal-0.3.0/src/printer.rs:232:9
    |
232 |         self.stylesheet.resolve_basic(&["paper"], None).build()
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
error: failed to compile `paper-terminal v0.3.0`, intermediate artifacts can be found at `/var/folders/6q/t2sh2rv11t1bt248_3yw16cr0000gp/T/cargo-installGDhm8B`

Caused by:
  Could not compile `paper-terminal`.

I do not receive the error if I clone the repo and build it locally. I do receive the error if I attempt to install the local copy with cargo install --path .

Haven't spent much time digging in yet, but will throw up a PR if I have time to look into whats up

Add option to rednder on the left side of terminal

Sometimes I use quite wide terminal windows on 4k display, most of the thing are written on the left side of it, but when I use paper it automatically place rendered markdown in the center of my terminal window which isn't very convenient. It would be great to have an option for the renderer to write a paper without this center alignment

SIGABRT "memory allocation of 8 Gibibyte failed" for simplest README.md

I'm using [email protected] on Linux 4.19 with Debian 10. I want to open the simplest Markdown file

README.md

a

It fails with "memory allocation of 8589934592 bytes failed" (8 Gibibyte)

strace: ($ strace paper README.md)

execve("/home/phip1611/.cargo/bin/paper", ["paper", "README.md"], 0x7ffd43017b48 /* 25 vars */) = 0
brk(NULL)                               = 0x55fb69285000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=25705, ...}) = 0
mmap(NULL, 25705, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb0e5138000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\3402\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=100712, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb0e5136000
mmap(NULL, 103472, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb0e511c000
mprotect(0x7fb0e511f000, 86016, PROT_NONE) = 0
mmap(0x7fb0e511f000, 69632, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7fb0e511f000
mmap(0x7fb0e5130000, 12288, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14000) = 0x7fb0e5130000
mmap(0x7fb0e5134000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x7fb0e5134000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260#\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=35808, ...}) = 0
mmap(NULL, 39904, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb0e5112000
mmap(0x7fb0e5114000, 16384, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7fb0e5114000
mmap(0x7fb0e5118000, 8192, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7fb0e5118000
mmap(0x7fb0e511a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7000) = 0x7fb0e511a000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@l\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=146968, ...}) = 0
mmap(NULL, 132288, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb0e50f1000
mmap(0x7fb0e50f7000, 61440, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7fb0e50f7000
mmap(0x7fb0e5106000, 24576, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x7fb0e5106000
mmap(0x7fb0e510c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1a000) = 0x7fb0e510c000
mmap(0x7fb0e510e000, 13504, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb0e510e000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\322\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1579448, ...}) = 0
mmap(NULL, 1581384, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb0e4f6e000
mmap(0x7fb0e4f7b000, 651264, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xd000) = 0x7fb0e4f7b000
mmap(0x7fb0e501a000, 872448, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xac000) = 0x7fb0e501a000
mmap(0x7fb0e50ef000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x180000) = 0x7fb0e50ef000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
)      = 14
getcwd("/tmp", 512)                     = 5
mmap(NULL, 2101248, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7fb0e4ba2000
mprotect(0x7fb0e4ba3000, 2097152, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0x7fb0e4da1e30, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7fb0e4da29d0, tls=0x7fb0e4da2700, child_tidptr=0x7fb0e4da29d0) = 13177
ioctl(0, TCGETS, {B9600 opost isig icanon echo ...}) = 0
epoll_create1(EPOLL_CLOEXEC)            = 10
epoll_ctl(10, EPOLL_CTL_ADD, 0, {EPOLLIN|EPOLLRDHUP|EPOLLET, {u32=0, u64=0}}) = 0
socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, [11, 12]) = 0
rt_sigaction(SIGWINCH, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGWINCH, {sa_handler=0x55fb67330790, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO|SA_NOCLDSTOP, sa_restorer=0x7fb0e5103730}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
epoll_ctl(10, EPOLL_CTL_ADD, 11, {EPOLLIN|EPOLLRDHUP|EPOLLET, {u32=1, u64=1}}) = 0
epoll_wait(10, [], 3, 0)                = 0
openat(AT_FDCWD, "/tmp/README.md", O_RDONLY|O_CLOEXEC) = 13
statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address)
statx(13, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=2, ...}) = 0
read(13, "a\n", 32)                     = 2
read(13, "", 30)                        = 0
close(13)                               = 0
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb0e4b78000
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=13178, si_uid=1000, si_status=127, si_utime=0, si_stime=0} ---
mremap(0x7fb0e4b78000, 135168, 266240, MREMAP_MAYMOVE) = 0x7fb0e4b37000
mremap(0x7fb0e4b37000, 266240, 528384, MREMAP_MAYMOVE) = 0x7fb0e4ab6000
mremap(0x7fb0e4ab6000, 528384, 1052672, MREMAP_MAYMOVE) = 0x7fb0e49b5000
mremap(0x7fb0e49b5000, 1052672, 2101248, MREMAP_MAYMOVE) = 0x7fb0e47b4000
mremap(0x7fb0e47b4000, 2101248, 4198400, MREMAP_MAYMOVE) = 0x7fb0e43b3000
mremap(0x7fb0e43b3000, 4198400, 8392704, MREMAP_MAYMOVE) = 0x7fb0df7ff000
mremap(0x7fb0df7ff000, 8392704, 16781312, MREMAP_MAYMOVE) = 0x7fb0de7fe000
mremap(0x7fb0de7fe000, 16781312, 33558528, MREMAP_MAYMOVE) = 0x7fb0dc7fd000
mremap(0x7fb0dc7fd000, 33558528, 67112960, MREMAP_MAYMOVE) = 0x7fb0d87fc000
mremap(0x7fb0d87fc000, 67112960, 134221824, MREMAP_MAYMOVE) = 0x7fb0d07fb000
mremap(0x7fb0d07fb000, 134221824, 268439552, MREMAP_MAYMOVE) = 0x7fb0c07fa000
mremap(0x7fb0c07fa000, 268439552, 536875008, MREMAP_MAYMOVE) = 0x7fb0a07f9000
mremap(0x7fb0a07f9000, 536875008, 1073745920, MREMAP_MAYMOVE) = 0x7fb0607f8000
mremap(0x7fb0607f8000, 1073745920, 2147487744, MREMAP_MAYMOVE) = 0x7fafe07f7000
mremap(0x7fafe07f7000, 2147487744, 4294971392, MREMAP_MAYMOVE) = 0x7faee07f6000
mremap(0x7faee07f6000, 4294971392, 8589938688, MREMAP_MAYMOVE) = -1 ENOMEM (Cannot allocate memory)
mmap(NULL, 8589938688, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
brk(0x55fd692ac000)                     = 0x55fb692a6000
mmap(NULL, 8590069760, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
mmap(NULL, 8589938688, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
write(2, "memory allocation of ", 21memory allocation of )   = 21
write(2, "8589934592", 108589934592)              = 10
write(2, " bytes failed\n", 14 bytes failed
)         = 14
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [], 8) = 0
getpid()                                = 13176
gettid()                                = 13176
tgkill(13176, 13176, SIGABRT)           = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=13176, si_uid=1000} ---
+++ killed by SIGABRT +++
[1]    13173 abort      strace paper README.md

Works fine on other plattforms.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.