Skip to content

Issue with execve without fork #7

@cosinusoidally

Description

@cosinusoidally

I ran into this issue when testing out my alternative bootstrap path under builder-hex0 fosslinux/live-bootstrap#407 (comment) . My cdrun utility seems to cause crashes under builder-hex0. With my tcc_bootstrap_alt path I do not rely on the availability of the cd command, instead I bundle my own utility that will chdir and then execve a command https://github.com/cosinusoidally/tcc_bootstrap_alt/blob/0.2/tcc_js/cdrun.c . I bundle this command so my alt tcc bootstrap can be entirely self contained and not have to rely on any external commands.

As far as I can tell things seem to start going wrong here

8B 60 0C # mov esp, [eax+0xC] ; no fork so reset initial stack to same as current process

#not_forked
8B 60 0C              # mov esp, [eax+0xC]       ; no fork so reset initial stack to same as current process
A1 DE 85 00 00        # mov eax, [next_process_num]
48                    # dec eax
EB 08                 # jmp prepare_stack

If I replace mov esp, [eax+0xC] with nops that seems to resolve the issue. If applied to this branch of live-bootstrap https://github.com/cosinusoidally/live-bootstrap/tree/builder-hex0-issue it then seems to run to completion (or at least I assume it will, it got as far as booting Linux before I terminated it). I'm not sure if that is a valid fix though as I'm not that familiar with the builder-hex0 code.

Not yet sure if my hack will break the mes build path (I'm just running that now, but it will take a while to run).

Note my builder-hex0-issue branch has been updated and is now pulling in an updated release of tcc_bootstrap_alt (https://github.com/cosinusoidally/tcc_bootstrap_alt/tree/0.2 which fixes a misalignment issue with malloc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions