FAQ Search Memberlist Usergroups
Jolt Country Forum Index
Register Profile Log in to check your private messages Log in
Log in Log in

Making Hugo Programs
Goto page Previous  1, 2
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors
View previous topic :: View next topic  
Author Message
ICJ
Guest





PostPosted: Mon Nov 24, 2014 9:31 am    Post subject: Reply with quote

Hm, didn't see your note till just now. I actually hopped on my Mac, did a make and tried to compile Cyberganked.

I get this:

➜ cyberganked2 git:(master) ✗ ./hc cyberganked.hug
[1] 41939 abort ./hc cyberganked.hug

Just putting this here for now.
Back to top
bruce



Joined: 04 Jun 2002
Posts: 2547

PostPosted: Wed Nov 26, 2014 5:20 pm    Post subject: Reply with quote

So how about making with the source?

I can compile Colossal Cave and start it and play to releasing the bird at the snake (all on my Mac) and it seems to be fine.
Back to top
View user's profile Send private message
Ice Cream Jonsey



Joined: 27 Apr 2002
Posts: 20088
Location: Colorado

PostPosted: Wed Nov 26, 2014 6:17 pm    Post subject: Reply with quote

Hmm. Bet it has something to do with the long file names in the WIP. Well, not long file names, but the subdirectories and filenames blew up the Unix version 'fore I fixed it.

Sent you an invitation to your f*s*f address. Through bitbucket. Thanks, man.
_________________
the dark and gritty...Ice Cream Jonsey!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
bruce



Joined: 04 Jun 2002
Posts: 2547

PostPosted: Wed Nov 26, 2014 7:13 pm    Post subject: Reply with quote

Well, a little dicking around (Mavericks doesn't include gdb anymore, so I needed to switch compiler to clang and then run under lldb) shows where it's crashing:

Code:

(lldb) bt
* thread #1: tid = 0x7e19f, 0x00007fff9034e286 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff9034e286 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff9247542f libsystem_pthread.dylib`pthread_kill + 90
    frame #2: 0x00007fff8cb65b53 libsystem_c.dylib`abort + 129
    frame #3: 0x00007fff8cb65cca libsystem_c.dylib`abort_report_np + 181
    frame #4: 0x00007fff8cb8bdb0 libsystem_c.dylib`__chk_fail + 48
    frame #5: 0x00007fff8cb8bdc0 libsystem_c.dylib`__chk_fail_overlap + 16
    frame #6: 0x00007fff8cb8bde2 libsystem_c.dylib`__chk_overlap + 34
    frame #7: 0x00007fff8cb8c117 libsystem_c.dylib`__strcat_chk + 81
    frame #8: 0x0000000100016cf9 hc`CompilerMem + 217 at hccomp.c:332
    frame #9: 0x0000000100017766 hc`Pass1 + 422 at hcpass.c:91
    frame #10: 0x0000000100000dbb hc`main(argc=2, argv=0x00007fff5fbffb50) + 171 at hc.c:64
    frame #11: 0x00007fff8ca9f5c9 libdyld.dylib`start + 1


So then we go to hccomp.c:
Code:

                        strcpy(buffer, word[1]);
                        strcat(buffer, word[2]);
                        strcat(buffer, word[3]);
                        word[1] = buffer;
                        words = 1;

It's that first strcat.

buffer is defined as extern char[] in hcheader.h.

There is no definition of buffer in hccomp.c.

So I guess it's getting implicitly initialized to some fixed size by strcpy? And then you're immediately appending to it, and the compiler is getting nervous?

So we simply declare buffer as char[256] at the top of CompilerMem.

Compilation now succeeds. And running the game in Hugor looks like it works. But still, let's see what else we find in the CLI tools.

Now he fails in the same way.

Code:

    frame #7: 0x00007fff8cb8bfbf libsystem_c.dylib`__strcpy_chk + 64
    frame #8: 0x000000010001a8e1 he`hugo_splitpath(path=0x00007fff5fbffc48, drive=0x00007fff5fbff9f0, dir=0x00007fff5fbff8f0, fname=0x00007fff5fbff7f0, ext=0x00007fff5fbff6f0) + 849 at hegcc.c:165

....which is....
Code:

        if (strcmp(dir, "") && fname[0]=='/') strcpy(fname, fname+1);


man strcpy tells us:

Code:

     The source and destination strings should not overlap, as the behavior is undefined.


Apparently gcc on Linux lets you get away with that.

So let's replace that with a cheesy strcpy implementation instead.

Code:

        if (strcmp(dir, "") && fname[0]=='/') {
          int i = 0;
          while(1) {
            fname[i]=fname[++i];
            if (fname[i] == '\0') break;
          }
        }


And now he also runs cyberganked.hex.

Moral of the story: string handling in C blows.
Back to top
View user's profile Send private message
bruce



Joined: 04 Jun 2002
Posts: 2547

PostPosted: Wed Nov 26, 2014 7:16 pm    Post subject: Reply with quote

Does Kent read this forum?

Here are the patches. No idea if 256 bytes is really right for the buffer, or if we're really guaranteed that fname is null-terminated, but hey. You get what you pay for.

Code:

--- hegcc.orig   2014-11-26 20:03:42.000000000 -0600
+++ hegcc.c   2014-11-26 20:11:15.000000000 -0600
@@ -162,7 +162,13 @@
         }
         else strcpy(fname,file);
 
-        if (strcmp(dir, "") && fname[0]=='/') strcpy(fname, fname+1);
+        if (strcmp(dir, "") && fname[0]=='/') {
+     int i = 0;
+     while(1) {
+       fname[i]=fname[++i];
+       if (fname[i] == '\0') break;
+     }
+   }
 }


Code:

--- hccomp.c.orig   2014-11-26 19:42:06.000000000 -0600
+++ hccomp.c   2014-11-26 19:53:39.000000000 -0600
@@ -317,6 +317,7 @@
 void CompilerMem(void)
 {
    char e[64];
+   char buffer[256];
 
    strcpy(e, "");
Back to top
View user's profile Send private message
Ice Cream Jonsey



Joined: 27 Apr 2002
Posts: 20088
Location: Colorado

PostPosted: Fri Nov 28, 2014 12:19 am    Post subject: Reply with quote

It's the bees knees.

^_____________^

I just wrote Kent on the mud to seeing about getting this patched officially. I will test it on my Mac when I go to work next.

Thanks, man. You have saved an entire race of people with this.
_________________
the dark and gritty...Ice Cream Jonsey!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Sun Nov 30, 2014 9:55 am    Post subject: Reply with quote

Awesome, bruce!
Back to top
View user's profile Send private message AIM Address
Ice Cream Jonsey



Joined: 27 Apr 2002
Posts: 20088
Location: Colorado

PostPosted: Wed Dec 24, 2014 10:06 am    Post subject: Reply with quote

Posting this link as the download locations are included:

http://www.joltcountry.com/phpBB2/viewtopic.php?t=9511
_________________
the dark and gritty...Ice Cream Jonsey!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors All times are GMT - 7 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001 phpBB Group

Theme by Kage Musha - RPG Garden

Copyrights and trademarks are all of the belonging company. No copyright Infringement intended