Announcement

Collapse

Maintenance

The forum could be offline for 30-60 minutes in the very near future for maintenance (said 3pm Pacific). I was behind on getting this notice. I do apologize.
See more
See less

PBCC/PBDLL GPF

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lance Edmonds
    replied
    It's not a bug, per se.

    The rule is that LOCAL ASCIIZ strings are allocated on the stack. STATIC and GLOBAL ASCIIZ strings are not allocated on the stack (and can therefore be of any size from 2 bytes to 2Gb), so they do not cause a stack overflow.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Bern Ertl
    replied
    Fred, I have not examined your example in great detail, but I think
    you can do away with the assignment of the NULL in the AddItem_udt
    function. It should already be initiallized to 0.

    Depending on what you are actually doing with your arrays, you might
    be better served managing a linked list to reduce all that memory
    copying. Or use an index pointer which wraps around the arrays.



    ------------------
    Bernard Ertl

    Leave a comment:


  • Fred Oxenby
    replied
    Perhaps I should explain the nonsens above...
    I am going to split an application into two.
    One "GUI-Less" application (Server)
    A seperate application (Clients) will connect to the server (TCP)
    for monitoring purposes.
    Several instances of the monitorong app could subscribe to the events
    in the Server.
    ----------
    Server hold its event in "round bobin" arrays where the last 10.000 messages
    are stored.
    ----------
    I insert the last event at pos 10000 and deletes event at pos 1




    ------------------
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

    Leave a comment:


  • Fred Oxenby
    replied
    I came across this "DIM ASCIIZ-problem" when investigating another oddity...
    Why is adding a udt to an array that awful slow,compared to adding a string

    Code:
    Type S_Typ
     S   as string * 349
     Nul as string * 1
    End Typ
    Global udt()    as S_Typ
    Global str()    as string
    Global MsgPos() as quad
    Global lastMsg  as quad
      
    Sub AddItem_udt(Msg$)
    Local A as S_Typ
     incr LastMsg
     A.S   = Msg$
     A.Nul = Chr$(0)
     Array Delete udt(1),A
     Array Delete MsgPos(1),LastMsg
    End Sub
      
    Sub AddItem_Str(Msg$)
     incr LastMsg
     Array Delete udt(1),Msg$ & Chr$(0)
     Array Delete MsgPos(1),LastMsg
    End Sub
    
    Function PBMain()as Long
    Redim udt(1:10000)
    Redim msgPos(1:10000) 
    Redim str(1:10000)
    
      For i& = 1 to 1000
       Additem_udt "This is string nr " & Format$(i&)
      Next
      
    ' THIS TAKES 33 SECONDS ON MY 400MHZ PII
      
      For i& = 1 to 1000
       AddItem_Str "This is string nr " & Format$(i&)
      Next
      
    ' THIS TAKES 1.03 seconds
    '---------------------------
     OPEN "C:\TEST.000" FOR BINARY AS #1 LEN=LEN(L_Typ)
     ARRAY SCAN MsgPos(),=31, TO x&
     FOR i& = x& TO 10000
      PUT 1,,udt(i&)
     NEXT
      
    ' THIS TAKES 0.010 sek-------
    '---------------------------
     OPEN "C:\TEST.001" FOR BINARY AS #1 
     ARRAY SCAN MsgPos(),=31, TO x&
     FOR i& = x& TO 10000
      PUT 1,,str(i&)
     NEXT
      
    ' THIS TAKES 0.010 sek-------
      
    End Function

    ------------------
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

    Leave a comment:


  • Florent Heyworth
    replied
    Hmm

    not sure if it directly has to do with the reserved stack size
    - could be a problem with string allocation. Another work around:

    Code:
    FUNCTION PBMAIN()AS LONG
        DIM b(0:3500001) AS BYTE
        DIM s AS STRING PTR * 3500000
        DIM s1 AS STRING PTR * 6
          
        s = VARPTR(b(0))
        s1 = s
        @s1 = "Hello"
     
        s1 = s1 + 3499993
        @s1 = " There"
        PRINT LEFT$(@s,5) + MID$(@s, 3499994)
     
        WAITKEY$
    END FUNCTION
    This was reported some time ago by Semen - Lance sent a report
    to R&D.

    Cheers

    Florent


    ------------------

    Leave a comment:


  • Fred Oxenby
    replied
    sorry, forgot stacksize (That is the point of failure,right?)
    DIM S as GLOBAL ASCIIZ * 3500000 will work


    ------------------
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

    Leave a comment:


  • Fred Oxenby
    started a topic PBCC/PBDLL GPF

    PBCC/PBDLL GPF

    This code will GPF:any comment welcome
    Code:
    Function PBMain()as long
    Dim S as ASCIIZ * 3500000
     
    End function

    ------------------
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

Working...
X