• General
  • idea: hosting a unitedbsd newsgroup

Wow....I want to be honest with you RVP, I posted this here hoping you'd show up and do some of your C magic. I'll report back in the following days as I'll recompile INN.

    JuvenalUrbino
    This is the simplest kind of memory-related bug to diagnose. Since you seem to be well up on your gdb fundamentals, I'll walk you through the GDB debugging-session so that you can figure out this class of bug on your own in the future:

    $ gdb /tmp/inn/bin/innbind
    Reading symbols from /tmp/inn/bin/innbind...
    (gdb) run "3,10,127.0.0.1,119"
    Starting program: /tmp/inn/bin/innbind "3,10,127.0.0.1,119"
    
    Program received signal SIGSEGV, Segmentation fault.
    0x0000756e3c422d39 in vector_split (string=0x7f7fffb24b95 "3,10,127.0.0.1,119", separator=44 ',', vector=0x756e3c771020)
        at vector.c:269
    269                 vector->strings[i++] = xstrndup(start, p - start);
    (gdb) l
    264             vector_resize(vector, count);
    265
    266         /* Walk the string and create the new strings with xstrndup. */
    267         for (start = string, p = string, i = 0; *p != '\0'; p++)
    268             if (*p == separator) {
    269                 vector->strings[i++] = xstrndup(start, p - start);
    270                 start = p + 1;
    271             }
    272         vector->strings[i++] = xstrndup(start, p - start);
    273         vector->count = i;
    (gdb) p vector
    $1 = (struct vector *) 0x756e3c771020
    (gdb) p *vector
    $3 = {count = 0, allocated = 4, strings = 0x3c771040}

    OK, notice how the address of vector and that of strings inside vector seem to differ wildly. But, look closer and you can discern a pattern: if you mask out some of the high-order bits, then the 2 addresses are in fact pretty close to each other--as they should be. At this point you go: "Ah...I know what this is" because:

    1. It's unlikely to be a fault in reallocarray() because a) that would've been noticed long ago, and b) reallocarray() will either return a NULL or SIGSEGV inside itself if you give it the wrong address--it won't return a wrong address like this.

    2. It's unlikely to be a GCC bug (for similar reasons)

    3. You notice the similarity in the LSB of the returned addresses (and have been bitten by this bug before).

    At this point you can write a short test program, then check the function prototype in /usr/include/stdlib.h and you pretty much know what's going on, but, let's continue anyway. Looking at the code we know that we have to check the return value of reallocarray() in vector_resize(). Put a couple of breakpoints before and after the function call:

    (gdb) b vector.c:263
    Breakpoint 1 at 0x756e3c422cad: file vector.c, line 263.
    (gdb) b vector.c:265
    Breakpoint 2 at 0x756e3c422cce: file vector.c, line 267.
    (gdb) run "3,10,127.0.0.1,119"
    The program being debugged has been started already.
    Start it from the beginning? (y or n) y
    Starting program: /tmp/inn/bin/innbind "3,10,127.0.0.1,119"
    
    Breakpoint 1, vector_split (string=0x7f7fff2f0475 "3,10,127.0.0.1,119", separator=44 ',', vector=0x73bc3a1c5020) at vector.c:263
    263         if (vector->allocated < count)
    (gdb) print *vector
    $4 = {count = 0, allocated = 1, strings = 0x73bc3a1c7008}

    vector->strings look OK at this point. Continue:

    (gdb) n
    264             vector_resize(vector, count);
    (gdb) n
    
    Breakpoint 2, vector_split (string=0x7f7fff2f0475 "3,10,127.0.0.1,119", separator=44 ',', vector=0x73bc3a1c5020) at vector.c:267
    267         for (start = string, p = string, i = 0; *p != '\0'; p++)
    (gdb) print *vector
    $5 = {count = 0, allocated = 4, strings = 0x3a1c5040}

    Now strings is clearly thrashed. You can set a breakpoint on vector_resize and single-step, checking the value of vector->strings as you go along, but, we know what's going on here by now...

    (gdb) quit
    A debugging session is active.
    
            Inferior 1 [process 5088] will be killed.
    
    Quit anyway? (y or n) y
    $

    The newsgroup is active (alt.unitedbsd). Connect to news://retrobsd.ddns.net at default port 119 with a NNTP client. For a quick brief on NNTP clients, see the tilde.club wiki. I'll probably write an introduction to slrn (which is what I use) on RetroBSD in the future.
    I'm keeping the group open to anybody (no auth) and unmoderated for the moment, as I'm positive we won't see any spam (my past experience with newsgroups outside of Usenet suggests me so).
    Given the small traffic I'm expecting to witness, I just set up a single group for everything, but more (e.g. for sharing links to actual news and blog posts on *BSD) can be added.

      7 days later

      JuvenalUrbino
      little typo:

      - getting things ready
      [...]
      $ for d in drafts macros misc
      > do mdkir -p ~/news/${d}
      > done

      Solution:
      alias mdkir="mkdir" 😆

      Also, I'm clearly doing something wrong

      ~ $ export NNTPSERVER=news://retrobsd.ddns.net
      ~ $ slrn --create
      slrn 1.0.3
      
      Loading /usr/pkg/share/slrn/slang/slrn.sl
      Reading startup file /home/dave/.slrnrc.***Warning: Unable to find a unique fully-qualified host name.
                  slrn will not generate any Message-IDs.
                  Please note that the "hostname" setting does not affect this;
                  see the "slrn reference manual" for details.
      
      Using newsrc file /home/dave/.jnewsrc for server news://retrobsd.ddns.net.
      Connecting to host retrobsd.ddns.net ...
      Unable to make connection. Giving up.
      
      Run-Time Error
      slrn fatal error:
      Failed to initialize server.

        pfr Solution:
        alias mdkir="mkdir" 😆

        Ty 🙂
        ...mdkir the new ultimate Unix swiss knife to make directories

        pfr Also, I'm clearly doing something wrong

        Specify a domainname in your /etc/rc.conf to get rid of the first warning; also put:

        127.0.1.1 hostname.yourdomain.tld hostname

        in /etc/hosts, and/or make sure /etc/resolv.conf has a domain entry.

        As for connectivity error, I think you just into a network connection downtime; trying pinging / reaching website next time to verify so.

          JuvenalUrbino

          I think it must have been down because I was able to reach news.tilde.club. Although I can't post for some reason. Does it require auth settings?

          Also, I just wonder about setting the environment variable export NNTPSERVER=news://retrobsd.ddns.net in .profile.. what if I want to access other servers (news.tilde.club for eg). Can I set more than one here?

          When I try to join news.tilde.club with slrn -h news://news.tilde.club:119 I get an empty buffer. I have to export the NNTPserver first then run slrn --create

          JuvenalUrbino Well, looks lime SD failed me....:/

          Unfortunately, @pfr, it is gone for a while and I need to restore it as I find the time. I only brought back the site for the moment. I really hate SDs: one unclean shutdown while writing stuff was already enough to compromise it irremediably.

          I'll look into booting from an external drive, it should be feasible as far as I know.

          As I lack a backup of the last week, my recent exchange with @yeti on the newsgroup however, is gone for real...

            JuvenalUrbino I'll look into booting from an external drive, it should be feasible as far as I know.

            @pfr the newsserver has been brought back. You might want to try to connect and see if you can post; Let me know if you have any problem

            pfr Any ideas about why I can't post to news.tilde.club?

            Honestly no, it should be opened for posting to anybody. What sort of error are you getting?

            • pfr replied to this.

              JuvenalUrbino
              Well this is embarrassing...

              gpg: can't open '/home/dave/.msmtp-password.gpg': No such file or directory
              gpg: decrypt_message failed: No such file or directory
              msmtp: cannot read output of 'gpg2 --no-tty -q -d ~/.msmtp-password.gpg'
              Command /usr/pkg/bin/msmtp -t returned exit status 78.  Press RETURN.

              Need help setting up msmtp 😅

                pfr by pressing 'r' you're writing a direct reply (mail) to parent poster. What you want instead is pressing 'f' to follow-up (nntp) on the thread.

                • pfr likes this.
                19 days later