Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 06:08 AM
Shane Ambler
 
Posts: n/a
Default Strange pgsql crash on MacOSX

I have a dual G4 1.25Ghz with 2GB RAM running Mac OSX 10.4.8 and
PostgreSQL 8.2.0

This only happened to me today and with everything I have tried it
always happens now - had been running fine before.

The only thing I can think of that has changed in the last few days is I
have installed the last 2 security updates from Apple and the X11 update
(X11 1.1.3) that Apple released a while ago -

http://www.apple.com/support/downloa...006008ppc.html
http://www.apple.com/support/downloa...clientppc.html

the first one I can't see having anything to do with postgres as it is I
believe only updating Java. The other one updates a few different areas
and may be the culprit.

I can't think of anything else I have changed just recently - certainly
not in the last couple of days.

To test and try and track down the cause I have restarted my machine
then started by unzipping the 8.2.0 released source and done the
following steps (this example is with clean data files and everything
default - the startup script has been there a while and using pg_ctl
instead makes no difference) make check passes all test -

../configure --prefix=/usr/local/pgsql
make check
sudo make install
cd /usr/local/pgsql
sudo mkdir data
sudo chown pgsqlgsql data
sudo chmod 700 data
sudo -u pgsql /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
sudo /Library/StartupItems/PostgreSQL/PostgreSQL start

Then I get the following -
[devbox:~] shane% psql
Welcome to psql 8.2.0, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

postgres=# \q
psql(24931) malloc: *** error for object 0x180a800: incorrect checksum
for freed object - object was probably modified after being freed, break
at szone_error to debug
psql(24931) malloc: *** set a breakpoint in szone_error to debug
Segmentation fault
[devbox:~] shane%

The serverlog gives me -
[devbox:local/pgsql/data] root# cat serverlog
LOG: database system was shut down at 2006-12-23 12:27:44 CST
LOG: checkpoint record is at 0/42BEB8
LOG: redo record is at 0/42BEB8; undo record is at 0/0; shutdown TRUE
LOG: next transaction ID: 0/593; next OID: 10820
LOG: next MultiXactId: 1; next MultiXactOffset: 0
LOG: database system is ready


Apple's crashreporter gives me -

Date/Time: 2006-12-23 12:28:21.499 +1030
OS Version: 10.4.8 (Build 8L127)
Report Version: 4

Command: psql
Path: /usr/local/pgsql/bin/psql
Parent: tcsh [294]

Version: ??? (???)

PID: 24931
Thread: 0

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x3430616b

Thread 0 Crashed:
0 libSystem.B.dylib 0x90006cd8 szone_free + 3148
1 libSystem.B.dylib 0x900152d0 fclose + 176
2 libedit.2.dylib 0x96b5c334 history_end + 1632
3 libedit.2.dylib 0x96b5c7bc history + 468
4 libedit.2.dylib 0x96b5ec58 write_history + 84
5 psql 0x00008350 saveHistory + 208
6 psql 0x00008428 finishInput + 120
7 libSystem.B.dylib 0x90014578 __cxa_finalize + 260
8 libSystem.B.dylib 0x90014444 exit + 36
9 psql 0x00001d00 _start + 764
10 psql 0x00001a00 start + 48

Thread 0 crashed with PPC Thread State 64:
srr0: 0x0000000090006cd8 srr1: 0x000000000000d030
vrsave: 0x0000000000000000
cr: 0x42002444 xer: 0x0000000020000001 lr:
0x0000000090006ca4 ctr: 0x00000000900143a0
r0: 0x0000000090006ca4 r1: 0x00000000bffff610 r2:
0x0000000042002442 r3: 0x000000000000000d
r4: 0x0000000000000000 r5: 0x000000000000000d r6:
0x0000000080808080 r7: 0x0000000000000003
r8: 0x0000000039333100 r9: 0x00000000bffff545 r10:
0x0000000000000000 r11: 0x0000000042002442
r12: 0x00000000900143a0 r13: 0x0000000000000000 r14:
0x0000000000000000 r15: 0x0000000000000000
r16: 0x0000000000000000 r17: 0x0000000000000052 r18:
0x0000000000000400 r19: 0x0000000000000054
r20: 0x00000000020000a4 r21: 0x000000000180a800 r22:
0x00000000a0001fac r23: 0x00000000020000a8
r24: 0x0000000000000002 r25: 0x0000000000000002 r26:
0x0000000000000001 r27: 0x0000000034306167
r28: 0x0000000001800000 r29: 0x000000000180a400 r30:
0x000000002e616767 r31: 0x00000000900060a0

Binary Images Description:
0x1000 - 0x36fff psql /usr/local/pgsql/bin/psql
0x3f000 - 0x54fff libpq.5.dylib /usr/local/pgsql/lib/libpq.5.dylib
0x8fe00000 - 0x8fe51fff dyld 45.3 /usr/lib/dyld
0x90000000 - 0x901bcfff libSystem.B.dylib /usr/lib/libSystem.B.dylib
0x90214000 - 0x90219fff libmathCommon.A.dylib
/usr/lib/system/libmathCommon.A.dylib
0x9110f000 - 0x9111dfff libz.1.dylib /usr/lib/libz.1.dylib
0x969c3000 - 0x969f1fff libncurses.5.4.dylib /usr/lib/libncurses.5.4.dylib
0x96b4d000 - 0x96b63fff libedit.2.dylib /usr/lib/libedit.2.dylib

Model: PowerMac3,6, BootROM 4.4.8f2, 2 processors, PowerPC G4 (3.2),
1.25 GHz, 2 GB
Graphics: NVIDIA GeForce4 MX, GeForce4 MX, AGP, 32 MB
Memory Module: DIMM0/J21, 512 MB, DDR SDRAM, PC2600U-25330
Memory Module: DIMM1/J22, 512 MB, DDR SDRAM, PC2600U-25330
Memory Module: DIMM2/J23, 512 MB, DDR SDRAM, PC2600U-25330
Memory Module: DIMM3/J20, 512 MB, DDR SDRAM, PC2600U-25330
AirPort: AirPort, 9.52
Network Service: Built-in Ethernet, Ethernet, en0
PCI Card: pci-bridge, pci, SLOT-3
PCI Card: firewire, ieee1394, 1x0
PCI Card: usb, usb, 1x1
PCI Card: usb, usb, 1x1
PCI Card: pci167e,225a, , 1x1
Parallel ATA Device: LITE-ON DVD SOHD-167T,
Parallel ATA Device: WDC WD1200JB-00FUA0, 111.79 GB
Parallel ATA Device: IBM-IC35L120AVVA07-0, 115.04 GB
USB Device: Apple Pro Keyboard, Mitsumi Electric, Up to 1.5 Mb/sec, 500 mA
USB Device: i350, Canon, Up to 12 Mb/sec, 500 mA
FireWire Device: unknown_device, unknown_value, Up to 400 Mb/sec



--

Shane Ambler
pgSQL@007Marketing.com

Get Sheeky @ http://Sheeky.Biz

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 06:08 AM
Tom Lane
 
Posts: n/a
Default Re: Strange pgsql crash on MacOSX

Shane Ambler <pgsql@007Marketing.com> writes:
> postgres=# \q
> psql(24931) malloc: *** error for object 0x180a800: incorrect checksum
> for freed object - object was probably modified after being freed, break
> at szone_error to debug
> psql(24931) malloc: *** set a breakpoint in szone_error to debug
> Segmentation fault


I think we've seen something like this before in connection with
readline/libedit follies. Does the crash go away if you invoke
psql with "-n" option? If so, exactly which version of readline or
libedit are you using?

FWIW, I do not see this on a fully up-to-date 10.4.8 G4 laptop.
I see

$ ls -l /usr/lib/libedit*
-rwxr-xr-x 1 root wheel 112404 Sep 29 20:59 /usr/lib/libedit.2.dylib
lrwxr-xr-x 1 root wheel 15 Apr 26 2006 /usr/lib/libedit.dylib -> libedit.2.dylib
$

so it seems that Apple did update libedit not too long ago ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 06:09 AM
Shane Ambler
 
Posts: n/a
Default Re: Strange pgsql crash on MacOSX

Shane Ambler wrote:
> Tom Lane wrote:
>> Shane Ambler <pgsql@007Marketing.com> writes:
>>> postgres=# \q
>>> psql(24931) malloc: *** error for object 0x180a800: incorrect checksum
>>> for freed object - object was probably modified after being freed, break
>>> at szone_error to debug
>>> psql(24931) malloc: *** set a breakpoint in szone_error to debug
>>> Segmentation fault

>>
>> I think we've seen something like this before in connection with
>> readline/libedit follies. Does the crash go away if you invoke
>> psql with "-n" option? If so, exactly which version of readline or
>> libedit are you using?



>
> psql -n stops the error.
>


I just found out the problem.

psql_history - I had tried to copy from a text file earlier that was
utf8 and came up with some errors, I guess these got into the history
file and stuffed it up.

Renamed it so it created a new one and all is fine now.

--

Shane Ambler
pgSQL@007Marketing.com

Get Sheeky @ http://Sheeky.Biz

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-12-2008, 06:09 AM
Tom Lane
 
Posts: n/a
Default Re: Strange pgsql crash on MacOSX

Shane Ambler <pgsql@007Marketing.com> writes:
> I just found out the problem.
> psql_history - I had tried to copy from a text file earlier that was
> utf8 and came up with some errors, I guess these got into the history
> file and stuffed it up.


Hm, so the question is: is it our bug or Apple's? If you kept the
busted history file, would you be willing to send me a copy?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-12-2008, 06:12 AM
Tom Lane
 
Posts: n/a
Default Re: Strange pgsql crash on MacOSX

Shane Ambler <pgsql@007Marketing.com> writes:
> Tom Lane wrote:
>> Hm, so the question is: is it our bug or Apple's? If you kept the
>> busted history file, would you be willing to send me a copy?


> The zip file attached has the psql_history file that crashes when
> quiting but doesn't appear to contain the steps I done when it first
> crashed.


So the answer is: it's Apple's bug, or at least not ours. libedit
contains a typo that causes it to potentially fail when saving strings
exceeding 256 bytes. Check out this code (around line 730 in history.c):

len = strlen(ev.str) * 4;
if (len >= max_size) {
char *nptr;
max_size = (len + 1023) & 1023;
nptr = h_realloc(ptr, max_size);

I think the intent of the max_size recalculation is to select the next
1K boundary larger than "len", but it actually produces a number *less*
than 1K. Probably "(len + 1023) & ~1023" was meant ... but even that
is wrong if len is exactly a multiple of 1024, because it will fail to
round up. So the buffer is realloc'd too small, and that results in
a potential memory clobber if the history entry is less than 1K, and a
guaranteed clobber if it's more.

The source code available from Apple shows that they got this code from
NetBSD originally

/* $NetBSD: history.c,v 1.25 2003/10/18 23:48:42 christos Exp $ */

so this may well be a pretty generic *BSD bug. Anyone clear on who to
report it to? I have no idea if libedit is an independent project...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-12-2008, 06:13 AM
Tom Lane
 
Posts: n/a
Default Re: Strange pgsql crash on MacOSX

I wrote:
> The source code available from Apple shows that they got this code from
> NetBSD originally
> /* $NetBSD: history.c,v 1.25 2003/10/18 23:48:42 christos Exp $ */
> so this may well be a pretty generic *BSD bug. Anyone clear on who to
> report it to? I have no idea if libedit is an independent project...


Some digging in the NetBSD CVS shows that they found both parts of this
bug more than two years ago:

http://cvsweb.netbsd.org/bsdweb.cgi/...25&r2=1.27&f=h

so the short and sweet answer is that Apple is behind the times.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:12 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846