www.digitalmars.com         C & C++   DMDScript  

c++.beta - 8.38.4: crash with qsort()

reply Detlef Riekenberg <driekenberg web.de> writes:
Hi.
While testing my Code with various Compiler, the DMC-Compiled Win32-EXE 
crashed during qsort(). (No Problems with OW 1.2_W32, GCC 3.2.2_RedHat9)

The Array (of int) is allocated dynamic. Size is incremended on demand.

The Array is filled with from (int)1 upto numitems.
9437182 Items: Sort OK.
9437183: Crash during qsort().

Mixed mode (example with 10 Items: 6,7,8,9,10,1,2,3,4,5) does work with 
12341234 Items but crashed with 20482048.
(I have not tested the switching Count.)

The Optimizer is already deactivated:
dmc.exe -c -w- -3 -f slist.c

Hm. Just locking at the Output: 9437183 is 0x008fffff !

-------------- cut -----------------
V:\src\test>slist  -v 9437183
firstarg=2      argc=3
2. argument: 9437183

verbose:        2
count:          9437183   startsize:    2359295   increment:    147455
mixed:          FALSE     reverse:      FALSE
use_bubblesort: FALSE     use_qsort:    FALSE     use_xsort:    FALSE

sizeof(struct SLIST)=28  sizeof(test)=4   count=9437183
0x007A2674           test (empty)
0x007A2674.data      0x007D0010 (0x007A69CC) (0x00000000) (0x00000000)
0x007A2674.actual    0  (data[0]=0x007A69CC = 8022476)
0x007A2674.used      0
0x007A2674.total     2359295  (increment=147455)

0x007A2674           test (created)
0x007A2674.data      0x07EC0010 (0x00000001) (0x00000002) (0x00000003)
0x007A2674.actual    9437182  (data[9437182]=0x008FFFFF = 9437183)
0x007A2674.used      9437183
0x007A2674.total     9584590  (increment=147455)

first: 0x1 = 1
last:  0x8fffff = 9437183
0x007A2674           test first() +  last()
0x007A2674.data      0x07EC0010 (0x00000001) (0x00000002) (0x00000003)
0x007A2674.actual    9437182  (data[9437182]=0x008FFFFF = 9437183)
0x007A2674.used      9437183
0x007A2674.total     9584590  (increment=147455)

sorting 0x07EC0010 -> 0x0A2C0008 (9437183 Items). sizeof(lptr) = 4

CRASH !!

------------------ CUT !!! -----------------

Any Ideas ?

If you want the Source, Send me a Mail.

PS: Sorry for my ugly English.
-- 
By by ...
       ... Detlef Riekenberg "driekenberg at web.de"

DSL/ISDN-Router + Firewall: ("www.fli4l.de")
Only 20 Watt: p1-133/48MB (IBM + AVM-DSL) mit FLi4L 2.1.4
Nov 13 2003
parent "Walter" <walter digitalmars.com> writes:
I could use a small test case source. -Walter

"Detlef Riekenberg" <driekenberg web.de> wrote in message
news:bp12ep$24gn$1 digitaldaemon.com...
 Hi.
 While testing my Code with various Compiler, the DMC-Compiled Win32-EXE
 crashed during qsort(). (No Problems with OW 1.2_W32, GCC 3.2.2_RedHat9)

 The Array (of int) is allocated dynamic. Size is incremended on demand.

 The Array is filled with from (int)1 upto numitems.
 9437182 Items: Sort OK.
 9437183: Crash during qsort().

 Mixed mode (example with 10 Items: 6,7,8,9,10,1,2,3,4,5) does work with
 12341234 Items but crashed with 20482048.
 (I have not tested the switching Count.)

 The Optimizer is already deactivated:
 dmc.exe -c -w- -3 -f slist.c

 Hm. Just locking at the Output: 9437183 is 0x008fffff !

 -------------- cut -----------------
 V:\src\test>slist  -v 9437183
 firstarg=2      argc=3
 2. argument: 9437183

 verbose:        2
 count:          9437183   startsize:    2359295   increment:    147455
 mixed:          FALSE     reverse:      FALSE
 use_bubblesort: FALSE     use_qsort:    FALSE     use_xsort:    FALSE

 sizeof(struct SLIST)=28  sizeof(test)=4   count=9437183
 0x007A2674           test (empty)
 0x007A2674.data      0x007D0010 (0x007A69CC) (0x00000000) (0x00000000)
 0x007A2674.actual    0  (data[0]=0x007A69CC = 8022476)
 0x007A2674.used      0
 0x007A2674.total     2359295  (increment=147455)

 0x007A2674           test (created)
 0x007A2674.data      0x07EC0010 (0x00000001) (0x00000002) (0x00000003)
 0x007A2674.actual    9437182  (data[9437182]=0x008FFFFF = 9437183)
 0x007A2674.used      9437183
 0x007A2674.total     9584590  (increment=147455)

 first: 0x1 = 1
 last:  0x8fffff = 9437183
 0x007A2674           test first() +  last()
 0x007A2674.data      0x07EC0010 (0x00000001) (0x00000002) (0x00000003)
 0x007A2674.actual    9437182  (data[9437182]=0x008FFFFF = 9437183)
 0x007A2674.used      9437183
 0x007A2674.total     9584590  (increment=147455)

 sorting 0x07EC0010 -> 0x0A2C0008 (9437183 Items). sizeof(lptr) = 4

 CRASH !!

 ------------------ CUT !!! -----------------

 Any Ideas ?

 If you want the Source, Send me a Mail.

 PS: Sorry for my ugly English.
 --
 By by ...
        ... Detlef Riekenberg "driekenberg at web.de"

 DSL/ISDN-Router + Firewall: ("www.fli4l.de")
 Only 20 Watt: p1-133/48MB (IBM + AVM-DSL) mit FLi4L 2.1.4

Nov 13 2003