Opened 5 years ago

Last modified 5 years ago

#303 reopened enhancement

__spawnvpe: Support more than 32K of arguments and 32KB enviroment.

Reported by: komh Owned by:
Priority: low Milestone: libc-0.7
Component: libc-backend Version: 0.6.5
Severity: minor Keywords: __spawnvpe
Cc:

Description (last modified by bird)

OS/2 only allows up to 32KB long string lists for arguments and 32KB for the environment. This causes problems for some programs, like the tests harness of automake v1.13.1. It would be nice to be able to pass longer strings to kLibC programs. On option is to use a temporary file or two.

Attachments (2)

envtest.c (1.8 KB) - added by komh 5 years ago.
main program of testcase
envtest2.c (490 bytes) - added by komh 5 years ago.
child program of testcase

Download all attachments as: .zip

Change History (9)

comment:1 Changed 5 years ago by komh

Further investigating revealed this problem was due to very large environment. This occurred when environment size was 65172. OS/2 allows up to 64K including argument size. Maybe environment size seemed to approach to the limit of OS/2.

Even though passing some infos through very large env vars, is absolutely insane appraoch, is it worth trying to workaround this problem like passing very long arguments ?

comment:2 Changed 5 years ago by komh

I've confirmed that the maximum environment size is 32KB(32768 bytes) except a mark of end, '\0', of an environemnt.

comment:3 Changed 5 years ago by bird

This is a OS specific limitation that would be very tedious to work around (would require shared memory, temporary argument file, or some other form of IPC to set up). The argument limit is expressed by the NCARGS (sys/params.h) and ARG_MAX (sys/syslimit.h) constants, there seems not to be any define giving the limit on the environment.

Now, I'd expect DosExecPgm? to fail with ERROR_BAD_ENVIRONMENT or ERROR_BAD_ARGUMENTS if either the environment or argument list is longer than ~32KB. Some quick experiments with a very large environment value and/or argument shows that it _spawnv and _spawnve does consistently fail. Maybe something more complicated is required? Or maybe the failure wasn't due to shells, but rather spawn failure?

Anyway, if you want anything fixed here, you need to supply a simple testcase that reproduces the issue.

comment:4 Changed 5 years ago by bird

  • Resolution set to needsmoreinput
  • Status changed from new to closed

comment:5 Changed 5 years ago by komh

  • Resolution needsmoreinput deleted
  • Status changed from closed to reopened

DosExecPgm? returned ERROR_BAD_ENVIRONMENT. I attach the testcases I used.

Changed 5 years ago by komh

main program of testcase

Changed 5 years ago by komh

child program of testcase

comment:6 Changed 5 years ago by bird

  • Component changed from libc to libc-backend
  • Description modified (diff)
  • Keywords __spawnvpe added
  • Summary changed from spawnvpe() set COMSPEC and OS2_SHELL to NULL in some cases to __spawnvpe: Support more than 32K of arguments and 32KB enviroment.
  • Type changed from defect to enhancement

comment:7 Changed 5 years ago by dmik

I can second the request. Here is another case when it screws things up: http://trac.netlabs.org/ports/ticket/58. Note that it seems that if there is a large number of arguments kLIBC screws up before coming down to DosExecPgm. At least, here, if you take the simple parent.c example from #343, build it with -Zwild-args and then run parent.exe * in a directory that contains very many files (got 1366 here), the parent.exe process will hard-hang the system (only the reboot helps) while just printing the argument list. Due to the hard hang, I can't tell more as all logs are killed by chkdsk after reboot (JFS). Perhaps, the argv array contains invalid pointers or such.

Note: See TracTickets for help on using tickets.