Author Topic: libc panic  (Read 5097 times)

Jochen Schäfer

  • Full Member
  • ***
  • Thank You
  • -Given: 18
  • -Receive: 8
  • Posts: 121
    • View Profile
libc panic
« on: July 31, 2015, 07:34:33 am »
Hi.

I'm porting nginx. I was able to build a binary and nginx can serve me static HTML pages.
I can stop nginx via process signaling. That just works fine.
But if I want to restart nginx, I get the following:
Code: [Select]
nginx: [alert] shmget(384) failed (22: Invalid argument)

LIBC PANIC!!
safesem mutex requested failed, rc=0x6. pmtx=5fe10960:{.hmtx=0x800100fb .fShared
=0x1}
pid=0x0fbb ppid=0x0b43 tid=0x0001 slot=0x009c pri=0x0200 mc=0x0001 ps=0x0017
U:\WORK\NGINX\OBJS\NGINX.EXE
Process dumping was disabled, use DUMPPROC / PROCDUMP to enable it.

Now, I have to reboot to get nginx running again.

I have the newest klibc installed and the binary is compiled with gcc 4.9.2.
Does anyone have suggestions, how to handle the problem?

Bye Jochen

PS: If someone wants to test the port, PM me.  I'll send you the binary.

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 11
  • -Receive: 174
  • Posts: 2471
    • View Profile
Re: libc panic
« Reply #1 on: July 31, 2015, 08:07:16 am »
Try adding -Zhigh-mem to your LDFLAGS

Jochen Schäfer

  • Full Member
  • ***
  • Thank You
  • -Given: 18
  • -Receive: 8
  • Posts: 121
    • View Profile
Re: libc panic
« Reply #2 on: July 31, 2015, 08:11:25 am »
I have already compiled nginx with -Zhigh-mem.
Actually, I used:
Code: [Select]
CFLAGS = -D__EMX__ -DEMX -DOS2 -Zmt  -D__ST_MT_ERRNO__ -g -march=pentium -mtune=pentium4 -static-libgccand
Code: [Select]
LDFLAGS = -Zomf -Zmap -Zhigh-mem -Zstack 8000 -D__ST_MT_ERRNO__ -static-libgcc -lmmap -Zexe
« Last Edit: July 31, 2015, 08:15:13 am by Jochen Schäfer »

Joop

  • Hero Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 59
  • Posts: 549
    • View Profile
Re: libc panic
« Reply #3 on: July 31, 2015, 07:20:39 pm »
All libc panics I had with Java had to do with a short of available memory. I don't know if this is the same in your situation.

Jochen Schäfer

  • Full Member
  • ***
  • Thank You
  • -Given: 18
  • -Receive: 8
  • Posts: 121
    • View Profile
Re: libc panic
« Reply #4 on: August 03, 2015, 01:41:40 pm »
I don't think, it's an memory problem. The problem is consistently the start of nginx after a previous shutdown.

The nginx code for the use of shared memory relies on the automatic removal of shared memory at process shutdown.
My guess is, that klibc ignores this flag and by the time nginx is started the second time, the shared semaphore is still in use and can't be recreated.
That leads to the lib panic.
Does someone know whether I can fetch a list of shared memory segments to release?

Boris

  • Sr. Member
  • ****
  • Thank You
  • -Given: 11
  • -Receive: 16
  • Posts: 310
    • View Profile
Re: libc panic
« Reply #5 on: August 03, 2015, 03:26:58 pm »
I know WatchCat can show semaphores per process.

Can also maybe Theseus 4 be useful?

ftp://ftp.boulder.ibm.com/ps/products/os2/fixes/v4.5warp/theseus4/thes4001.exe

By the way, I sent you a PM some time ago...
PS: If someone wants to test the port, PM me.  I'll send you the binary.
LIABILITY DISCLAIMER: this is how I understand and what I know, I may be highly inaccurate, or even completely wrong! There are no claims, promises, or guarantees about the accuracy, completeness, or adequacy of the contents of my posts. Think on your own!

Jochen Schäfer

  • Full Member
  • ***
  • Thank You
  • -Given: 18
  • -Receive: 8
  • Posts: 121
    • View Profile
Re: libc panic
« Reply #6 on: August 03, 2015, 03:35:53 pm »
Hi Boris.

Thanks for the hints. Imwill look into the tools.
I didn't forget your PM, I just didn't get to packaging and uploading the binary. Sorry.
Hope to get to it this evening.

Andy Willis

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 10
  • Posts: 210
    • View Profile
Re: libc panic
« Reply #7 on: August 03, 2015, 05:15:53 pm »
What does -D__ST_MT_ERRNO__ do?  I have recently come across it and couldn't determine what its purpose was.

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 11
  • -Receive: 174
  • Posts: 2471
    • View Profile
Re: libc panic
« Reply #8 on: August 03, 2015, 05:27:19 pm »
What does -D__ST_MT_ERRNO__ do?  I have recently come across it and couldn't determine what its purpose was.

On EMX, it was needed when using the multithreading version of the library along with -Zmt. Now it is just a no-op as kLIBC only supports multi-threading. (Programs aimed at DOS had to be single threaded)